.option('-f, --file <filename>',`complete path of the filename where the bash completion will be stored (default to ${this.defaultFilename}).`,this.defaultFilename)
.option('-y, --force','don\'t ask for file overwrite confirmation')
.action(this.commandAction.bind(this));
.description('generate bash completion')
.option('-f, --file <filename>')
.option('-y, --force','don\'t ask for file overwrite confirmation')
The easiest way to install the completion is to append the content of the generated file to the end of the ${TextStyle.CODE('~/.bash_completion')} file or to overwrite it, if it only contains the 'dojo' completion.
spinner.succeed(`Bash completion successfully written in ${TextStyle.CODE(filename)}`);
if (showInstructions){
console.log(`
The easiest way to install the completion is to append the content of the generated file to the end of the ${TextStyle.CODE('~/.bash_completion')} file or to overwrite it, if it only contains the 'dojo' completion.
constspinner:ora.Ora=ora(`Renaming ${TextStyle.CODE(filename)} in ${TextStyle.CODE(old_filename)} ...`).start();
try{
renameSync(filename,old_filename);
spinner.succeed(`Renaming success: ${TextStyle.CODE(filename)} in ${TextStyle.CODE(old_filename)}`);
if (confirm){
this.writeFile(options.file);
if (showWarning){
console.log(`${TextStyle.WARNING('Warning:')} Your ${TextStyle.CODE(filename)} was renamed ${TextStyle.CODE(old_filename)}. If this was not intended please revert this change.`);
}
}catch (error){
spinner.fail(`Renaming failed: ${error}.`);
}
}
/* The completion command must do the following:
- if a file is provided:
- if force is not enabled:
- check if the file exists:
- if it exists, prompt the user that it will be erased
- if ok is given write the file and prompt that a backup has been created
- else create the file containing the completion
- else
- if force is not enabled:
- check if the default file exists:
- if it exists, prompt the user that it will be erased:
- if ok is given write the file and prompt that a backup has been created