cli icon indicating copy to clipboard operation
cli copied to clipboard

`ignite s chain`: allows to generate files in the current directory

Open lumtis opened this issue 2 years ago • 2 comments

Is your feature request related to a problem or issue you encountered? Please describe. Sometimes we want to create a new chain but we already have the git repo setup. Or recreating the chain in a new branch from a repo.

We should have an option to create the chain in the current dir without creating a git file. Same behavior as other scaffolding commands

Describe the solution you'd like

Introduce a flag like --unpack that performs this behavior

ignite s chain github.com/lubdt/foo --unpack

lumtis avatar Aug 11 '22 11:08 lumtis

Interesting idea!

What if we make it more explicit by using a flag --skip-git, which will not init a git repo regardless if you're scaffolding a chain in a current directory or the regular way.

And modify the --path flag, so that passing . will scaffold a chain in a current dir.

The following will do what you propose:

ignite s chain github.com/lubdt/foo --skip-git --path .

This will create the files in hello/world without creating a foo directory.

ignite s chain github.com/lubdt/foo --skip-git --path hello/world

fadeev avatar Aug 11 '22 12:08 fadeev

I would use --path . by default personally with --skip-git because if you don't want to init a git then means you have one

lumtis avatar Aug 11 '22 13:08 lumtis

@scottcarterco looking for some feedback here.

I personally think that we should not include the --skip-git flag.

Instead, we should check if a git repo exists or not in the given path. If git repo exists, we can prompt user if they want to use the existing repo. Else, we create one

aljo242 avatar Dec 16 '22 16:12 aljo242

Why not both? For developers who already know they want to skip, why not allow a flag to be appended so that it automatically knows to do so. Similar to specifying r for recursive. If that flag was not appended, we can prompt them with something such as A git repo already exists. Would you like to create a new one? Y/N or similar approach with different language.

scottcarterco avatar Dec 16 '22 16:12 scottcarterco

Jump on this:

For the path, I would act like git clone, bc developers are used to it:

  • git clone github.com/ignite/example will clone into a new directory called example
  • git clone github.com/ignite/example newdir will clone into a new directory called newdir
  • git clone github.com/ignite/example . will clone into the current directory.

For the skip git, the underlying code calls xgit.InitAndCommit() which does not invoke git init if the passed dir is already inside a git repository (this is a recent change), so you don't end up with multiple nested git repos.

tbruyelle avatar Dec 16 '22 18:12 tbruyelle