grim/convey
Clone
Summary
Browse
Changes
Graph
required_version should be required-version to match other attributes.
2018-02-18, Gary Kramlich
b4e7049d5ec1
required_version should be required-version to match other attributes.
// Convey
// Copyright 2016-2018 Gary Kramlich <grim@reaperworld.com>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package
aws
import
(
"fmt"
"github.com/alecthomas/kingpin"
"bitbucket.org/rw_grim/convey/tasks"
)
// ParseCommand is a super stripped down kingpin parser that will parse aws
// command line options and return a convey task or an error
func
ParseCommand
(
argv
[]
string
)
(
tasks
.
Task
,
error
)
{
app
:=
kingpin
.
New
(
""
,
""
)
ecr
:=
app
.
Command
(
"ecr"
,
""
)
getLogin
:=
ecr
.
Command
(
"get-login"
,
""
)
region
:=
getLogin
.
Flag
(
"region"
,
""
).
String
()
getLogin
.
Flag
(
"no-include-email"
,
""
).
Bool
()
cmd
,
err
:=
app
.
Parse
(
argv
[
1
:])
if
err
!=
nil
{
return
nil
,
err
}
var
task
tasks
.
Task
switch
cmd
{
case
"ecr get-login"
:
task
=
&
ECRGetLogin
{
Region
:
*
region
,
}
}
if
task
!=
nil
{
return
task
,
nil
}
return
nil
,
fmt
.
Errorf
(
"unable to parse aws command line '%v'"
,
argv
)
}