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
Automate
Agent sessions
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
d196195c
Commit
d196195c
authored
Apr 19, 2022
by
Malte Bauch
Browse files
Options
Downloads
Patches
Plain Diff
WIP
parent
774c7aaa
No related branches found
No related tags found
1 merge request
!284
Improve usability and better output formatting for gosndc
Pipeline
#99403
failed
Apr 19, 2022
Stage: build
Stage: test
Stage: analyze
Stage: integration-test
Changes
2
Pipelines
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
cli/cmd/pndRemove.go
+10
-4
10 additions, 4 deletions
cli/cmd/pndRemove.go
cli/cmd/prompt.go
+5
-1
5 additions, 1 deletion
cli/cmd/prompt.go
with
15 additions
and
5 deletions
cli/cmd/pndRemove.go
+
10
−
4
View file @
d196195c
...
@@ -32,7 +32,8 @@ POSSIBILITY OF SUCH DAMAGE.
...
@@ -32,7 +32,8 @@ POSSIBILITY OF SUCH DAMAGE.
package
cmd
package
cmd
import
(
import
(
log
"github.com/sirupsen/logrus"
"code.fbi.h-da.de/danet/gosdn/api/go/gosdn/core"
"github.com/pterm/pterm"
"github.com/google/uuid"
"github.com/google/uuid"
"github.com/spf13/cobra"
"github.com/spf13/cobra"
...
@@ -42,19 +43,24 @@ import (
...
@@ -42,19 +43,24 @@ import (
var
pndRemoveCmd
=
&
cobra
.
Command
{
var
pndRemoveCmd
=
&
cobra
.
Command
{
Use
:
"remove"
,
Use
:
"remove"
,
Aliases
:
[]
string
{
"rm"
},
Aliases
:
[]
string
{
"rm"
},
Short
:
"
TODO - not yet implemented
"
,
Short
:
"
Removes the PND with the provided ID
"
,
Long
:
`TODO - not yet implemented`
,
Long
:
"Removes the PND with the provided ID"
,
RunE
:
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
error
{
RunE
:
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
error
{
spinner
,
_
:=
pterm
.
DefaultSpinner
.
Start
(
"Fetching changes for type: "
,
cType
.
String
())
pid
,
err
:=
uuid
.
Parse
(
args
[
0
])
pid
,
err
:=
uuid
.
Parse
(
args
[
0
])
if
err
!=
nil
{
if
err
!=
nil
{
spinner
.
Fail
(
err
)
return
err
return
err
}
}
resp
,
err
:=
pndAdapter
.
RemovePnd
(
pid
)
resp
,
err
:=
pndAdapter
.
RemovePnd
(
pid
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
log
.
Infof
(
"Deletion of PND with ID %v: %s"
,
pid
,
resp
.
GetStatus
()
.
String
())
if
resp
.
GetStatus
()
==
core
.
Status_STATUS_OK
{
spinner
.
Success
(
"PND has been deleted, ID: "
,
pid
)
}
spinner
.
Fail
()
return
nil
return
nil
},
},
}
}
...
...
This diff is collapsed.
Click to expand it.
cli/cmd/prompt.go
+
5
−
1
View file @
d196195c
...
@@ -197,7 +197,7 @@ func cobraCommandCompletion(currCmd *cobra.Command, d prompt.Document, inputFlag
...
@@ -197,7 +197,7 @@ 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
,
pndRemoveCmd
:
if
len
(
inputSplit
)
<
3
||
(
len
(
inputSplit
)
==
3
&&
d
.
GetWordBeforeCursor
()
!=
""
)
{
if
len
(
inputSplit
)
<
3
||
(
len
(
inputSplit
)
==
3
&&
d
.
GetWordBeforeCursor
()
!=
""
)
{
suggestions
:=
c
.
updateSuggestionsThroughFunc
(
d
,
getPnds
)
suggestions
:=
c
.
updateSuggestionsThroughFunc
(
d
,
getPnds
)
return
cobraCommandCompletion
(
cmd
,
d
,
inputFlags
,
suggestions
)
return
cobraCommandCompletion
(
cmd
,
d
,
inputFlags
,
suggestions
)
...
@@ -210,6 +210,10 @@ func completionBasedOnCmd(c *PromptCompleter, cmd *cobra.Command, inputSplit []s
...
@@ -210,6 +210,10 @@ func completionBasedOnCmd(c *PromptCompleter, cmd *cobra.Command, inputSplit []s
if
len
(
inputSplit
)
<
3
||
(
len
(
inputSplit
)
==
3
&&
d
.
GetWordBeforeCursor
()
!=
""
)
{
if
len
(
inputSplit
)
<
3
||
(
len
(
inputSplit
)
==
3
&&
d
.
GetWordBeforeCursor
()
!=
""
)
{
return
c
.
updateSuggestionsThroughFunc
(
d
,
getConfirmedChanges
)
return
c
.
updateSuggestionsThroughFunc
(
d
,
getConfirmedChanges
)
}
}
case
deviceRemoveCmd
:
if
len
(
inputSplit
)
<
3
||
(
len
(
inputSplit
)
==
3
&&
d
.
GetWordBeforeCursor
()
!=
""
)
{
return
c
.
updateSuggestionsThroughFunc
(
d
,
getDevices
)
}
case
deviceGetCmd
,
deviceSetCmd
:
case
deviceGetCmd
,
deviceSetCmd
:
return
deviceGetCompletion
(
c
,
d
,
inputSplit
)
return
deviceGetCompletion
(
c
,
d
,
inputSplit
)
case
deviceShowCmd
:
case
deviceShowCmd
:
...
...
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