github.com/jkawamoto/roadie-azure@v0.3.5/commands.go (about) 1 // 2 // commands.go 3 // 4 // Copyright (c) 2017 Junpei Kawamoto 5 // 6 // This file is part of Roadie Azure. 7 // 8 // Roadie Azure is free software: you can redistribute it and/or modify 9 // it under the terms of the GNU General Public License as published by 10 // the Free Software Foundation, either version 3 of the License, or 11 // (at your option) any later version. 12 // 13 // Roadie Azure is distributed in the hope that it will be useful, 14 // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 // GNU General Public License for more details. 17 // 18 // You should have received a copy of the GNU General Public License 19 // along with Roadie Azure. If not, see <http://www.gnu.org/licenses/>. 20 // 21 22 package main 23 24 import ( 25 "fmt" 26 "os" 27 28 "github.com/jkawamoto/roadie-azure/command" 29 "github.com/urfave/cli" 30 ) 31 32 // GlobalFlags defines global flags. 33 var GlobalFlags = []cli.Flag{} 34 35 // Commands defines sub-commands. 36 var Commands = []cli.Command{ 37 { 38 Name: "init", 39 Usage: "run the initialization process", 40 ArgsUsage: "<config file> <instance name>", 41 Action: command.CmdInit, 42 }, 43 { 44 Name: "exec", 45 Usage: "execute the given script under the given configuration", 46 ArgsUsage: "<config file> <script file> <instance name>", 47 Action: command.CmdExec, 48 }, 49 } 50 51 // CommandNotFound prints an error message when a given command is not supported. 52 func CommandNotFound(c *cli.Context, command string) { 53 fmt.Fprintf( 54 os.Stderr, "%s: '%s' is not a %s command. See '%s --help'.", 55 c.App.Name, command, c.App.Name, c.App.Name) 56 os.Exit(2) 57 }