Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
go-orusapi
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
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
orus-io
go-orusapi
Commits
dafdd8181250
Commit
dafdd8181250
authored
1 month ago
by
Christophe de Vienne
Browse files
Options
Downloads
Patches
Plain Diff
cmd.WithSubcommand now takes descriptions
parent
1d8b85be4337
No related branches found
No related tags found
No related merge requests found
Pipeline
#121145
failed
1 month ago
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
cmd/program.go
+12
-4
12 additions, 4 deletions
cmd/program.go
with
12 additions
and
4 deletions
cmd/program.go
+
12
−
4
View file @
dafdd818
...
@@ -36,8 +36,10 @@
...
@@ -36,8 +36,10 @@
}
}
type
subcommand
[
E
any
]
struct
{
type
subcommand
[
E
any
]
struct
{
name
string
name
string
init
func
(
*
Program
[
E
])
any
shortDescription
string
longDescription
string
init
func
(
*
Program
[
E
])
any
}
}
type
Program
[
E
any
]
struct
{
type
Program
[
E
any
]
struct
{
...
@@ -186,7 +188,10 @@
...
@@ -186,7 +188,10 @@
}
}
}
}
func
WithSubcommand
[
E
any
](
name
string
,
init
func
(
*
Program
[
E
])
any
)
Option
[
E
]
{
func
WithSubcommand
[
E
any
](
name
string
,
shortDescription
string
,
longDescription
string
,
init
func
(
*
Program
[
E
])
any
,
)
Option
[
E
]
{
return
func
(
program
*
Program
[
E
])
{
return
func
(
program
*
Program
[
E
])
{
program
.
setupSubcommands
=
append
(
program
.
setupSubcommands
,
subcommand
[
E
]{
program
.
setupSubcommands
=
append
(
program
.
setupSubcommands
,
subcommand
[
E
]{
name
:
name
,
name
:
name
,
...
@@ -279,7 +284,10 @@
...
@@ -279,7 +284,10 @@
}
}
for
_
,
subcmd
:=
range
program
.
setupSubcommands
{
for
_
,
subcmd
:=
range
program
.
setupSubcommands
{
if
_
,
err
:=
parser
.
AddCommand
(
subcmd
.
name
,
subcmd
.
name
,
""
,
subcmd
.
init
(
&
program
));
err
!=
nil
{
if
_
,
err
:=
parser
.
AddCommand
(
subcmd
.
name
,
subcmd
.
shortDescription
,
subcmd
.
shortDescription
,
subcmd
.
init
(
&
program
),
);
err
!=
nil
{
panic
(
err
)
panic
(
err
)
}
}
}
}
...
...
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