changes in the fn organization and aliases (#475)

This commit is contained in:
Pedro Nasser
2017-01-05 16:00:31 -02:00
committed by C Cirello
parent bec75118c2
commit e68df5d154
4 changed files with 78 additions and 16 deletions

View File

@@ -21,7 +21,7 @@ func apps() cli.Command {
return cli.Command{
Name: "apps",
Usage: "operate applications",
Usage: "manage applications",
ArgsUsage: "fn apps",
Subcommands: []cli.Command{
{

27
fn/images.go Normal file
View File

@@ -0,0 +1,27 @@
package main
import (
"github.com/iron-io/functions_go"
"github.com/urfave/cli"
)
type imagesCmd struct {
*functions.AppsApi
}
func images() cli.Command {
return cli.Command{
Name: "images",
Usage: "manage function images",
ArgsUsage: "fn images",
Subcommands: []cli.Command{
build(),
deploy(),
bump(),
call(),
push(),
run(),
testfn(),
},
}
}

View File

@@ -9,33 +9,68 @@ import (
"github.com/urfave/cli"
)
const fnversion = "0.1.39"
const fnversion = "0.1.40"
var aliases = map[string]cli.Command{
"build": build(),
"bump": bump(),
"deploy": deploy(),
}
func aliasesFn() []cli.Command {
cmds := []cli.Command{}
for alias, cmd := range aliases {
cmd.Name = alias
cmd.Hidden = true
cmds = append(cmds, cmd)
}
return cmds
}
func main() {
app := cli.NewApp()
app.Name = "fn"
app.Version = fnversion
app.Authors = []cli.Author{{Name: "iron.io"}}
app.Usage = "IronFunctions command line tools"
app.UsageText = `Check the manual at https://github.com/iron-io/functions/blob/master/fn/README.md
app.Description = "IronFunctions command line tools"
app.UsageText = `Check the manual at https://github.com/iron-io/functions/blob/master/fn/README.md`
cli.AppHelpTemplate = `{{.Name}} {{.Version}}{{if .Description}}
{{.Description}}{{end}}
USAGE:
{{if .UsageText}}{{.UsageText}}{{else}}{{.HelpName}} {{if .VisibleFlags}}[global options]{{end}}{{if .Commands}} command [command options]{{end}} {{if .ArgsUsage}}{{.ArgsUsage}}{{else}}[arguments...]{{end}}{{end}}
ENVIRONMENT VARIABLES:
API_URL - IronFunctions remote API address`
app.CommandNotFound = func(c *cli.Context, cmd string) { fmt.Fprintf(os.Stderr, "command not found: %v\n", cmd) }
API_URL - IronFunctions remote API address{{if .VisibleCommands}}
COMMANDS:{{range .VisibleCategories}}{{if .Name}}
{{.Name}}:{{end}}{{range .VisibleCommands}}
{{join .Names ", "}}{{"\t"}}{{.Usage}}{{end}}{{end}}{{end}}{{if .VisibleFlags}}
ALIASES:
build (images build)
bump (images bump)
deploy (images deploy)
GLOBAL OPTIONS:
{{range $index, $option := .VisibleFlags}}{{if $index}}
{{end}}{{$option}}{{end}}{{end}}
`
app.CommandNotFound = func(c *cli.Context, cmd string) {
fmt.Fprintf(os.Stderr, "command not found: %v\n", cmd)
}
app.Commands = []cli.Command{
apps(),
build(),
bump(),
call(),
deploy(),
initFn(),
lambda(),
push(),
apps(),
routes(),
run(),
testfn(),
images(),
lambda(),
version(),
}
app.Commands = append(app.Commands, aliasesFn()...)
app.Run(os.Args)
}

View File

@@ -27,7 +27,7 @@ func routes() cli.Command {
return cli.Command{
Name: "routes",
Usage: "operate routes",
Usage: "manage routes",
ArgsUsage: "fn routes",
Subcommands: []cli.Command{
{