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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Dojo Project (HES-SO)
Projects
UI
DojoCLI
Commits
90e59802
Verified
Commit
90e59802
authored
1 year ago
by
orestis.malaspin
Browse files
Options
Downloads
Patches
Plain Diff
module instead of class
parent
1d08aa9f
No related branches found
No related tags found
1 merge request
!8
Draft: Resolve "Add bash completion helper function"
Pipeline
#29337
passed
1 year ago
Stage: code_quality
Stage: test
Changes
2
Pipelines
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
NodeApp/src/commander/CommanderApp.ts
+2
-2
2 additions, 2 deletions
NodeApp/src/commander/CommanderApp.ts
NodeApp/src/helpers/AutoCompletionHelper.ts
+45
-50
45 additions, 50 deletions
NodeApp/src/helpers/AutoCompletionHelper.ts
with
47 additions
and
52 deletions
NodeApp/src/commander/CommanderApp.ts
+
2
−
2
View file @
90e59802
...
...
@@ -9,7 +9,7 @@ import { stateConfigFile } from '../config/ConfigFiles';
import
semver
from
'
semver/preload
'
;
import
{
version
}
from
'
../config/Version
'
;
import
Config
from
'
../config/Config
'
;
import
Auto
Completion
Helper
from
'
../helpers/AutoCompletionHelper
'
;
import
{
getBash
Completion
}
from
'
../helpers/AutoCompletionHelper
'
;
class
CommanderApp
{
...
...
@@ -44,7 +44,7 @@ class CommanderApp {
this
.
registerCommands
();
AutoCompletionHelper
.
getBashCompletion
(
this
.
program
)
getBashCompletion
(
this
.
program
)
// AutoCompletionHelper.getCommands(this.program)
this
.
program
.
parse
();
...
...
This diff is collapsed.
Click to expand it.
NodeApp/src/helpers/AutoCompletionHelper.ts
+
45
−
50
View file @
90e59802
import
{
Command
}
from
'
commander
'
;
interface
Node
{
readonly
name
:
string
;
readonly
children
:
Array
<
Node
>
;
...
...
@@ -59,8 +60,7 @@ function flatten(tree: Node): Node[] {
}
class
AutoCompletionHelper
{
private
printWordsGrandParents
(
cmd
:
Node
)
{
function
printWordsGrandParents
(
cmd
:
Node
)
{
let
prefix
=
""
if
(
cmd
.
parent
!==
undefined
)
{
console
.
log
(
"
case
\"
${grand_parent}
\"
in
"
)
...
...
@@ -77,12 +77,12 @@ class AutoCompletionHelper {
}
}
private
buildCommandNode
(
root
:
Command
):
Node
{
function
buildCommandNode
(
root
:
Command
):
Node
{
return
createNode
(
root
.
name
(),
root
.
commands
.
map
((
sc
)
=>
getSubNode
(
sc
,
root
)))
}
getBashCompletion
(
root
:
Command
)
{
const
tree
=
this
.
buildCommandNode
(
root
)
export
function
getBashCompletion
(
root
:
Command
)
{
const
tree
=
buildCommandNode
(
root
)
console
.
log
(
"
#/usr/bin/env bash
"
)
console
.
log
(
"
function _dojo_completions()
"
)
console
.
log
(
"
{
"
)
...
...
@@ -99,7 +99,7 @@ class AutoCompletionHelper {
const
words
=
"
words=
\"
"
+
cmd
.
children
.
map
(
c
=>
c
.
name
).
join
(
"
"
)
+
"
\"
"
console
.
log
(
words
)
}
else
if
(
cmd
!=
undefined
&&
node
.
length
>
1
)
{
node
.
forEach
(
n
=>
this
.
printWordsGrandParents
(
n
))
node
.
forEach
(
n
=>
printWordsGrandParents
(
n
))
}
console
.
log
(
"
;;
"
)
}
...
...
@@ -111,8 +111,3 @@ class AutoCompletionHelper {
console
.
log
(
"
}
"
)
console
.
log
(
"
complete -F _dojo_completions dojo
"
)
}
}
export
default
new
AutoCompletionHelper
();
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment