| package main |
| |
| import ( |
| "fmt" |
| "os" |
| |
| "code.hackerspace.pl/hscloud/go/workspace" |
| "github.com/spf13/cobra" |
| ) |
| |
| var rootCmd = &cobra.Command{ |
| Use: "hscloud", |
| Short: "hscloud kitchesink tool", |
| Long: `A single entrypoint tool to interact with a hscloud git checkout.`, |
| } |
| |
| var workspaceCmd = &cobra.Command{ |
| Use: "workspace", |
| Short: "Print root path of hscloud checkuot", |
| Long: `This returns the directory path containing WORKSPACE. It works both from 'bazel run', when invoked as a tool in bazel or when called manually. Feel free to use this in your sh_binary scripts.`, |
| Run: func(cmd *cobra.Command, args []string) { |
| wd, err := workspace.Get() |
| if err != nil { |
| fmt.Fprintf(os.Stderr, "%v", err) |
| os.Exit(1) |
| } |
| fmt.Println(wd) |
| }, |
| } |
| |
| func main() { |
| rootCmd.AddCommand(workspaceCmd) |
| if err := rootCmd.Execute(); err != nil { |
| fmt.Fprintln(os.Stderr, err) |
| os.Exit(1) |
| } |
| } |