Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
goSDN
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Analyze
Contributor 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
danet
goSDN
Commits
f1aad4c0
Commit
f1aad4c0
authored
Apr 19, 2022
by
Malte Bauch
Browse files
Options
Downloads
Patches
Plain Diff
WIP
parent
142bc63f
No related branches found
No related tags found
1 merge request
!284
Improve usability and better output formatting for gosndc
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
cli/cmd/prompt.go
+27
-4
27 additions, 4 deletions
cli/cmd/prompt.go
with
27 additions
and
4 deletions
cli/cmd/prompt.go
+
27
−
4
View file @
f1aad4c0
...
@@ -198,15 +198,36 @@ func cobraCommandCompletion(currCmd *cobra.Command, d prompt.Document, inputFlag
...
@@ -198,15 +198,36 @@ func cobraCommandCompletion(currCmd *cobra.Command, d prompt.Document, inputFlag
func
completionBasedOnCmd
(
c
*
PromptCompleter
,
cmd
*
cobra
.
Command
,
inputSplit
[]
string
,
inputFlags
[]
string
,
d
prompt
.
Document
)
[]
prompt
.
Suggest
{
func
completionBasedOnCmd
(
c
*
PromptCompleter
,
cmd
*
cobra
.
Command
,
inputSplit
[]
string
,
inputFlags
[]
string
,
d
prompt
.
Document
)
[]
prompt
.
Suggest
{
switch
cmd
{
switch
cmd
{
case
pndUseCmd
,
pndGetCmd
:
case
pndUseCmd
,
pndGetCmd
:
return
cobraCommandCompletion
(
cmd
,
d
,
inputFlags
,
getPnds
())
if
len
(
inputSplit
)
<
3
||
(
len
(
inputSplit
)
==
3
&&
d
.
GetWordBeforeCursor
()
!=
""
)
{
pnds
,
err
:=
getPnds
()
if
err
!=
nil
{
return
[]
prompt
.
Suggest
{}
}
return
cobraCommandCompletion
(
cmd
,
d
,
inputFlags
,
pnds
)
}
case
commitCmd
:
case
commitCmd
:
return
getChangesByType
(
pnd
.
ChangeState_CHANGE_STATE_PENDING
)
if
len
(
inputSplit
)
<
3
||
(
len
(
inputSplit
)
==
3
&&
d
.
GetWordBeforeCursor
()
!=
""
)
{
ch
,
err
:=
getChangesByType
(
pnd
.
ChangeState_CHANGE_STATE_PENDING
)
if
err
!=
nil
{
return
[]
prompt
.
Suggest
{}
}
return
ch
}
case
confirmCmd
:
case
confirmCmd
:
return
getChangesByType
(
pnd
.
ChangeState_CHANGE_STATE_COMMITTED
)
if
len
(
inputSplit
)
<
3
||
(
len
(
inputSplit
)
==
3
&&
d
.
GetWordBeforeCursor
()
!=
""
)
{
ch
,
err
:=
getChangesByType
(
pnd
.
ChangeState_CHANGE_STATE_COMMITTED
)
if
err
!=
nil
{
return
[]
prompt
.
Suggest
{}
}
return
ch
}
case
deviceGetCmd
,
deviceSetCmd
:
case
deviceGetCmd
,
deviceSetCmd
:
return
deviceGetCompletion
(
c
,
d
,
inputSplit
)
return
deviceGetCompletion
(
c
,
d
,
inputSplit
)
case
deviceShowCmd
:
case
deviceShowCmd
:
devices
,
_
:=
getDevices
()
devices
,
err
:=
getDevices
()
if
err
!=
nil
{
return
[]
prompt
.
Suggest
{}
}
return
devices
return
devices
case
deviceCmd
:
case
deviceCmd
:
c
.
currentDeviceSuggestions
=
nil
c
.
currentDeviceSuggestions
=
nil
...
@@ -214,6 +235,8 @@ func completionBasedOnCmd(c *PromptCompleter, cmd *cobra.Command, inputSplit []s
...
@@ -214,6 +235,8 @@ func completionBasedOnCmd(c *PromptCompleter, cmd *cobra.Command, inputSplit []s
default
:
default
:
return
cobraCommandCompletion
(
cmd
,
d
,
inputFlags
,
[]
prompt
.
Suggest
{})
return
cobraCommandCompletion
(
cmd
,
d
,
inputFlags
,
[]
prompt
.
Suggest
{})
}
}
return
[]
prompt
.
Suggest
{}
}
}
var
exitCmd
=
&
cobra
.
Command
{
var
exitCmd
=
&
cobra
.
Command
{
...
...
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
sign in
to comment