cli
cli copied to clipboard
`ignite s chain`: allows to generate files in the current directory
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
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
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
@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
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.
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 calledexample
-
git clone github.com/ignite/example newdir
will clone into a new directory callednewdir
-
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.