Description
Right now we use the cli.js with argv
options that gets parsed and then we have a if-else
construct.
Like:
const argv = yargs
.alias('o1', 'option1')
.description('o1', 'description for o1')
.alias('o2', 'option2')
.description('o2', 'description for o2')
.help()
.argv;
if (argv.option1) {
// do something
} else if (argv.option2) {
// do something else
} else {
// do default stuff
}
But maybe it would be more readable if we use commands instead? For example with the commandDir()
from yargs.
So the cli.js
is really only the cli. Because the recoverTasks()
function is also part of the cli but is not named as one.
Like:
yargs
.commandDir('cmds')
.demandCommand()
.help()
.argv;
and a dir like:
.
|
+-- cmds
| |
| +-- default.js
| |
| +-- recover.js
|
+-- tasks
| +-- recover-tasks
| |
| +-- default-tasks
|
+-- helpers
|
+-- cli.js
Because i think a --flag
should more used to be a boolean. But right now --recover
can take a string as argument
. And after this refactoring this would be sgr [command] <argument>
=> sgr recover backup
. This would be a breaking change since the --recover
flag would change to the recover
command that can take an argument
. The default command would be the same sgr
or semantic-git-release
.
@JPeer264 what do you think about this?