Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
小 白蛋
Nomad
Commits
73990d68
Commit
73990d68
authored
7 years ago
by
Alex Dadgar
Committed by
Chelsea Holland Komlo
7 years ago
Browse files
Options
Download
Email Patches
Plain Diff
Autocomplete global flags
parent
ac7669e9
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
command/helpers.go
+12
-0
command/helpers.go
command/job_status.go
+7
-6
command/job_status.go
command/meta.go
+35
-15
command/meta.go
with
54 additions
and
21 deletions
+54
-21
command/helpers.go
+
12
-
0
View file @
73990d68
...
@@ -12,6 +12,7 @@ import (
...
@@ -12,6 +12,7 @@ import (
gg
"github.com/hashicorp/go-getter"
gg
"github.com/hashicorp/go-getter"
"github.com/hashicorp/nomad/api"
"github.com/hashicorp/nomad/api"
"github.com/hashicorp/nomad/jobspec"
"github.com/hashicorp/nomad/jobspec"
"github.com/posener/complete"
"github.com/ryanuber/columnize"
"github.com/ryanuber/columnize"
)
)
...
@@ -318,3 +319,14 @@ func getVersion(job *api.Job) uint64 {
...
@@ -318,3 +319,14 @@ func getVersion(job *api.Job) uint64 {
return
0
return
0
}
}
// mergeAutocompleteFlags is used to join multiple flag completion sets.
func
mergeAutocompleteFlags
(
flags
...
complete
.
Flags
)
complete
.
Flags
{
merged
:=
make
(
map
[
string
]
complete
.
Predictor
,
len
(
flags
))
for
_
,
f
:=
range
flags
{
for
k
,
v
:=
range
f
{
merged
[
k
]
=
v
}
}
return
merged
}
This diff is collapsed.
Click to expand it.
command/job_status.go
+
7
-
6
View file @
73990d68
...
@@ -61,12 +61,13 @@ func (c *JobStatusCommand) Synopsis() string {
...
@@ -61,12 +61,13 @@ func (c *JobStatusCommand) Synopsis() string {
}
}
func
(
c
*
JobStatusCommand
)
AutocompleteFlags
()
complete
.
Flags
{
func
(
c
*
JobStatusCommand
)
AutocompleteFlags
()
complete
.
Flags
{
return
complete
.
Flags
{
return
mergeAutocompleteFlags
(
c
.
Meta
.
AutocompleteFlags
(
FlagSetClient
),
"-all-allocs"
:
complete
.
PredictNothing
,
complete
.
Flags
{
"-evals"
:
complete
.
PredictNothing
,
"-all-allocs"
:
complete
.
PredictNothing
,
"-short"
:
complete
.
PredictNothing
,
"-evals"
:
complete
.
PredictNothing
,
"-verbose"
:
complete
.
PredictNothing
,
"-short"
:
complete
.
PredictNothing
,
}
"-verbose"
:
complete
.
PredictNothing
,
})
}
}
func
(
c
*
JobStatusCommand
)
AutocompleteArgs
()
complete
.
Predictor
{
func
(
c
*
JobStatusCommand
)
AutocompleteArgs
()
complete
.
Predictor
{
...
...
This diff is collapsed.
Click to expand it.
command/meta.go
+
35
-
15
View file @
73990d68
...
@@ -10,6 +10,7 @@ import (
...
@@ -10,6 +10,7 @@ import (
"github.com/hashicorp/nomad/api"
"github.com/hashicorp/nomad/api"
"github.com/mitchellh/cli"
"github.com/mitchellh/cli"
"github.com/mitchellh/colorstring"
"github.com/mitchellh/colorstring"
"github.com/posener/complete"
"golang.org/x/crypto/ssh/terminal"
"golang.org/x/crypto/ssh/terminal"
)
)
...
@@ -93,6 +94,25 @@ func (m *Meta) FlagSet(n string, fs FlagSetFlags) *flag.FlagSet {
...
@@ -93,6 +94,25 @@ func (m *Meta) FlagSet(n string, fs FlagSetFlags) *flag.FlagSet {
return
f
return
f
}
}
// AutocompleteFlags returns a set of flag completions for the given flag set.
func
(
m
*
Meta
)
AutocompleteFlags
(
fs
FlagSetFlags
)
complete
.
Flags
{
if
fs
&
FlagSetClient
==
0
{
return
nil
}
return
complete
.
Flags
{
"-address"
:
complete
.
PredictAnything
,
"-region"
:
complete
.
PredictAnything
,
"-no-color"
:
complete
.
PredictNothing
,
"-ca-cert"
:
complete
.
PredictFiles
(
"*"
),
"-ca-path"
:
complete
.
PredictDirs
(
"*"
),
"-client-cert"
:
complete
.
PredictFiles
(
"*"
),
"-client-key"
:
complete
.
PredictFiles
(
"*"
),
"-insecure"
:
complete
.
PredictNothing
,
"-tls-skip-verify"
:
complete
.
PredictNothing
,
}
}
// Client is used to initialize and return a new API client using
// Client is used to initialize and return a new API client using
// the default command line arguments and env vars.
// the default command line arguments and env vars.
func
(
m
*
Meta
)
Client
()
(
*
api
.
Client
,
error
)
{
func
(
m
*
Meta
)
Client
()
(
*
api
.
Client
,
error
)
{
...
@@ -144,32 +164,32 @@ func generalOptionsUsage() string {
...
@@ -144,32 +164,32 @@ func generalOptionsUsage() string {
The region of the Nomad servers to forward commands to.
The region of the Nomad servers to forward commands to.
Overrides the NOMAD_REGION environment variable if set.
Overrides the NOMAD_REGION environment variable if set.
Defaults to the Agent's local region.
Defaults to the Agent's local region.
-no-color
-no-color
Disables colored command output.
Disables colored command output.
-ca-cert=<path>
-ca-cert=<path>
Path to a PEM encoded CA cert file to use to verify the
Path to a PEM encoded CA cert file to use to verify the
Nomad server SSL certificate. Overrides the NOMAD_CACERT
Nomad server SSL certificate. Overrides the NOMAD_CACERT
environment variable if set.
environment variable if set.
-ca-path=<path>
-ca-path=<path>
Path to a directory of PEM encoded CA cert files to verify
Path to a directory of PEM encoded CA cert files to verify
the Nomad server SSL certificate. If both -ca-cert and
the Nomad server SSL certificate. If both -ca-cert and
-ca-path are specified, -ca-cert is used. Overrides the
-ca-path are specified, -ca-cert is used. Overrides the
NOMAD_CAPATH environment variable if set.
NOMAD_CAPATH environment variable if set.
-client-cert=<path>
-client-cert=<path>
Path to a PEM encoded client certificate for TLS authentication
Path to a PEM encoded client certificate for TLS authentication
to the Nomad server. Must also specify -client-key. Overrides
to the Nomad server. Must also specify -client-key. Overrides
the NOMAD_CLIENT_CERT environment variable if set.
the NOMAD_CLIENT_CERT environment variable if set.
-client-key=<path>
-client-key=<path>
Path to an unencrypted PEM encoded private key matching the
Path to an unencrypted PEM encoded private key matching the
client certificate from -client-cert. Overrides the
client certificate from -client-cert. Overrides the
NOMAD_CLIENT_KEY environment variable if set.
NOMAD_CLIENT_KEY environment variable if set.
-tls-skip-verify
-tls-skip-verify
Do not verify TLS certificate. This is highly not recommended. Verification
Do not verify TLS certificate. This is highly not recommended. Verification
will also be skipped if NOMAD_SKIP_VERIFY is set.
will also be skipped if NOMAD_SKIP_VERIFY is set.
`
`
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment