Skip to content
Snippets Groups Projects
Commit d50b7418 authored by michael.minelli's avatar michael.minelli
Browse files

Sonar => Restore o. malaspinas comments

parent eaf6bb41
Branches
Tags
1 merge request!10Resolve "Add sonar integration"
Pipeline #29991 failed
Subproject commit ffc5d65f9f0f0e825688177425e526131aa84631 Subproject commit f572bf3afa0a98675247df85c599b5d1e5a62d0d
...@@ -11,12 +11,12 @@ import GlobalHelper from '../../../helpers ...@@ -11,12 +11,12 @@ import GlobalHelper from '../../../helpers
class CompletionBashCommand extends CommanderCommand { class CompletionBashCommand extends CommanderCommand {
protected commandName: string = 'bash'; protected commandName: string = 'bash';
private installPath = path.join(os.homedir(), '.bash_completion'); private readonly installPath = path.join(os.homedir(), '.bash_completion');
protected defineCommand() { protected defineCommand() {
GlobalHelper.completionCommandDefinition(this.command) GlobalHelper.completionCommandDefinition(this.command)
.description('generate bash completion') .description('generate bash completion')
.action(this.commandAction.bind(this)); .action(this.commandAction.bind(this));
} }
private writeFile(filename: string, showInstructions: boolean) { private writeFile(filename: string, showInstructions: boolean) {
...@@ -46,20 +46,21 @@ For more details: ${ TextStyle.URL('https://github.com/scop/bash-completion/blob ...@@ -46,20 +46,21 @@ For more details: ${ TextStyle.URL('https://github.com/scop/bash-completion/blob
} }
/* The completion command must do the following: /* The completion command must do the following:
- if a file is provided: - if a file is provided:
- if force is not enabled: - if force is not enabled:
- check if the file exists: - check if the bash completion file exists:
- if it exists, prompt the user that it will be erased - if it exists, prompt the user that it will be overwritten
- if ok is given write the file and prompt that a backup has been created - if ok is given write the file and prompt that a backup has been created
- else create the file containing the completion - else create the file containing the completion
- else - else
- if force is not enabled: - if force is not enabled:
- check if the default file exists: - check if the default file exists:
- if it exists, prompt the user that it will be erased: - 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 - if ok is given write the file and prompt that a backup has been created
- else - else
- create the file containing the completion - create the file containing the completion
*/ - create a .zprofile or append the appropriate commands into the .zprofile file
*/
protected async commandAction(options: { file: string, force: boolean }): Promise<void> { protected async commandAction(options: { file: string, force: boolean }): Promise<void> {
const filePath = path.resolve(options.file ?? this.installPath); // change that if file is empty const filePath = path.resolve(options.file ?? this.installPath); // change that if file is empty
const showInstructions = !!options.file; const showInstructions = !!options.file;
......
...@@ -15,8 +15,8 @@ class CompletionFishCommand extends CommanderCommand { ...@@ -15,8 +15,8 @@ class CompletionFishCommand extends CommanderCommand {
protected defineCommand() { protected defineCommand() {
GlobalHelper.completionCommandDefinition(this.command) GlobalHelper.completionCommandDefinition(this.command)
.description('generate fish completion') .description('generate fish completion')
.action(this.commandAction.bind(this)); .action(this.commandAction.bind(this));
} }
private writeFile(filename: string, showInstructions: boolean) { private writeFile(filename: string, showInstructions: boolean) {
...@@ -41,20 +41,20 @@ ${ TextStyle.CODE(` cp -i ${ filename } ~/.config/fish/completions # interactiv ...@@ -41,20 +41,20 @@ ${ TextStyle.CODE(` cp -i ${ filename } ~/.config/fish/completions # interactiv
/* The completion command must do the following: /* The completion command must do the following:
- if a file is provided: - if a file is provided:
- if force is not enabled: - if force is not enabled:
- check if the file exists: - check if the file exists:
- if it exists, prompt the user that it will be erased - 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 - if ok is given write the file and prompt that a backup has been created
- else create the file containing the completion - else create the file containing the completion
- else - else
- if force is not enabled: - if force is not enabled:
- check if the default file exists: - check if the default file exists:
- if it exists, prompt the user that it will be erased: - 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 - if ok is given write the file and prompt that a backup has been created
- else - else
- create the file containing the completion - create the file containing the completion
*/ */
protected async commandAction(options: { file: string, force: boolean }): Promise<void> { protected async commandAction(options: { file: string, force: boolean }): Promise<void> {
const filePath = path.resolve(options.file ?? this.installPath); // change that if file is empty const filePath = path.resolve(options.file ?? this.installPath); // change that if file is empty
const showInstructions = !!options.file; const showInstructions = !!options.file;
......
...@@ -11,20 +11,20 @@ import GlobalHelper from '../../../helpers ...@@ -11,20 +11,20 @@ import GlobalHelper from '../../../helpers
class CompletionZshCommand extends CommanderCommand { class CompletionZshCommand extends CommanderCommand {
protected commandName: string = 'zsh'; protected commandName: string = 'zsh';
private zprofile: string = path.join(homedir(), '.zprofile'); private readonly zprofile: string = path.join(homedir(), '.zprofile');
private bash_completion = path.join(homedir(), '.bash_completion'); private readonly bashCompletion = path.join(homedir(), '.bash_completion');
private load_bash_completion = ` private readonly loadBashCompletion = `
# Added by DojoCLI # Added by DojoCLI
autoload -U +X compinit && compinit autoload -U +X compinit && compinit
autoload -U +X bashcompinit && bashcompinit autoload -U +X bashcompinit && bashcompinit
source ${ this.bash_completion } source ${ this.bashCompletion }
`; `;
protected defineCommand() { protected defineCommand() {
GlobalHelper.completionCommandDefinition(this.command) GlobalHelper.completionCommandDefinition(this.command)
.description('generate zsh completion, which is derived from the bash completion') .description('generate zsh completion, which is derived from the bash completion')
.action(this.commandAction.bind(this)); .action(this.commandAction.bind(this));
} }
private writeFile(filename: string, showInstructions: boolean) { private writeFile(filename: string, showInstructions: boolean) {
...@@ -92,7 +92,7 @@ source ${ filename } ...@@ -92,7 +92,7 @@ source ${ filename }
} }
} else { } else {
try { try {
fs.writeFileSync(path, this.load_bash_completion); fs.writeFileSync(path, this.loadBashCompletion);
spinner.succeed(`Zsh profile written.`); spinner.succeed(`Zsh profile written.`);
} catch ( error ) { } catch ( error ) {
spinner.fail(`Error writing in ${ this.zprofile }`); spinner.fail(`Error writing in ${ this.zprofile }`);
...@@ -101,23 +101,23 @@ source ${ filename } ...@@ -101,23 +101,23 @@ source ${ filename }
} }
/* The completion command must do the following: /* The completion command must do the following:
- if a file is provided: - if a file is provided:
- if force is not enabled: - if force is not enabled:
- check if the bash completion file exists: - check if the bash completion file exists:
- if it exists, prompt the user that it will be overwritten - if it exists, prompt the user that it will be overwritten
- if ok is given write the file and prompt that a backup has been created - if ok is given write the file and prompt that a backup has been created
- else create the file containing the completion - else create the file containing the completion
- else - else
- if force is not enabled: - if force is not enabled:
- check if the default file exists: - check if the default file exists:
- if it exists, prompt the user that it will be erased: - 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 - if ok is given write the file and prompt that a backup has been created
- else - else
- create the file containing the completion - create the file containing the completion
- create a .zprofile or append the appropriate commands into the .zprofile file - create a .zprofile or append the appropriate commands into the .zprofile file
*/ */
protected async commandAction(options: { file: string, force: boolean }): Promise<void> { protected async commandAction(options: { file: string, force: boolean }): Promise<void> {
const filePath = path.resolve(options.file ?? this.bash_completion); // change that if file is empty const filePath = path.resolve(options.file ?? this.bashCompletion); // change that if file is empty
const showInstructions = !!options.file; const showInstructions = !!options.file;
if ( !(await tryRenameFile(filePath, options.force)) ) { // means renaming was interrupted if ( !(await tryRenameFile(filePath, options.force)) ) { // means renaming was interrupted
return; return;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment