Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
DojoCLI
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Dojo Project (HES-SO)
Projects
UI
DojoCLI
Merge requests
!9
Resolve "Add zsh, fish, and bash shell completion helper function generation as well as the related command"
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Resolve "Add zsh, fish, and bash shell completion helper function generation as well as the related command"
4-add-fish-shell-completion-helper-function-generation
into
v3.5.1
Overview
7
Commits
42
Pipelines
51
Changes
6
Merged
orestis.malaspin
requested to merge
4-add-fish-shell-completion-helper-function-generation
into
v3.5.1
1 year ago
Overview
7
Commits
42
Pipelines
51
Changes
6
Expand
Closes
#4 (closed)
0
0
Merge request reports
Viewing commit
5e601ba1
Show latest version
6 files
+
227
−
7
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
6
Search (e.g. *.vue) (Ctrl+P)
Verified
5e601ba1
added all 3 completion commands
· 5e601ba1
orestis.malaspin
authored
1 year ago
NodeApp/src/commander/completion/subcommands/CompletionBashCommand.ts
0 → 100644
+
61
−
0
Options
import
{
existsSync
,
writeFileSync
}
from
'
fs
'
;
import
inquirer
from
'
inquirer
'
;
import
CommanderCommand
from
'
../../CommanderCommand
'
;
import
{
generateBashCompletion
,
getRoot
}
from
'
../../../helpers/AutoCompletionHelper
'
;
class
CompletionBashCommand
extends
CommanderCommand
{
protected
commandName
:
string
=
'
bash
'
;
protected
default_filename
:
string
=
'
./dojo_bash_completion.sh
'
writeFile
(
filename
:
string
)
{
const
installInstructions
:
string
=
`
The easiest way to install the completion is to append the content of the
generated file to the end of the '~/.bash_completion' file or to
overwrite it, if it only contains the 'dojo' completion.
This can be performed by either
cat
${
filename
}
> ~/.bash_completion # overwrites .bash_completion
cat
${
filename
}
>> ~/.bash_completion # appends to .bash_completion
For more details: <https://github.com/scop/bash-completion/blob/master/README.md>
`
try
{
writeFileSync
(
filename
,
generateBashCompletion
(
getRoot
(
this
.
command
)))
console
.
log
(
`Bash completion successfully written.`
)
console
.
log
(
`
${
installInstructions
}
`
)
}
catch
(
error
)
{
console
.
log
(
`Error:
${
error
}
, failed to write
${
filename
}
`
)
}
}
protected
defineCommand
()
{
this
.
command
.
description
(
'
generate bash completion
'
)
.
option
(
`-f, --file <filename>', 'complete path of the filename where the bash completion will be stored (default to
${
this
.
default_filename
}
).`
)
.
action
(
this
.
commandAction
.
bind
(
this
));
}
protected
async
commandAction
(
options
:
{
file
?:
string
}):
Promise
<
void
>
{
const
filename
=
options
.
file
??
this
.
default_filename
if
(
existsSync
(
filename
))
{
// File exists in path
const
confirm
:
boolean
=
(
await
inquirer
.
prompt
({
name
:
'
confirm
'
,
message
:
`
${
options
.
file
}
is going to be overwritten. Are you sure?`
,
type
:
'
confirm
'
,
default
:
false
})).
confirm
;
if
(
confirm
)
{
this
.
writeFile
(
filename
)
}
}
else
{
this
.
writeFile
(
filename
)
}
}
}
export
default
new
CompletionBashCommand
();
\ No newline at end of file
Loading