Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
packer
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kristopher Ruzic
packer
Commits
74d812a7
Commit
74d812a7
authored
Jun 02, 2013
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
packer: Much smarter CLI
parent
fcd86673
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
5 deletions
+23
-5
packer/environment.go
packer/environment.go
+23
-5
No files found.
packer/environment.go
View file @
74d812a7
...
...
@@ -160,6 +160,26 @@ func (e *coreEnvironment) Cli(args []string) (result int, err error) {
return
1
,
nil
}
// This variable will track whether or not we're supposed to print
// the help or not.
isHelp
:=
false
for
_
,
arg
:=
range
args
{
if
arg
==
"-h"
||
arg
==
"--help"
{
isHelp
=
true
break
}
}
// Trim up to the command name
for
i
,
v
:=
range
args
{
if
v
[
0
]
!=
'-'
{
args
=
args
[
i
:
]
break
}
}
log
.
Printf
(
"command + args: %#v"
,
args
)
version
:=
args
[
0
]
==
"version"
if
!
version
{
for
_
,
arg
:=
range
args
{
...
...
@@ -191,11 +211,9 @@ func (e *coreEnvironment) Cli(args []string) (result int, err error) {
// If we're supposed to print help, then print the help of the
// command rather than running it.
for
_
,
arg
:=
range
args
{
if
arg
==
"--help"
||
arg
==
"-h"
{
e
.
ui
.
Say
(
command
.
Help
())
return
0
,
nil
}
if
isHelp
{
e
.
ui
.
Say
(
command
.
Help
())
return
0
,
nil
}
log
.
Printf
(
"Executing command: %s
\n
"
,
args
[
0
])
...
...
Write
Preview
Markdown
is supported
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