diff --git a/createcmd.go b/createcmd.go new file mode 100644 index 0000000..fa1d8a7 --- /dev/null +++ b/createcmd.go @@ -0,0 +1,37 @@ +package main + +import ( + "fmt" + + "github.com/spf13/cobra" +) + +type CreateOptions struct { + WorkingDirectory string +} + +var ( + createOpts = CreateOptions{} + + createCmd = &cobra.Command{ + Use: "create ", + Short: "creates a new Unit file", + Long: `The create command creates a new systemd Unit file`, + RunE: func(cmd *cobra.Command, args []string) error { + if len(args) < 1 { + return fmt.Errorf("create needs an executable to create a Unit file for") + } + return executeCreate() + }, + } +) + +func executeCreate() error { + return nil +} + +func init() { + createCmd.PersistentFlags().StringVarP(&createOpts.WorkingDirectory, "workingdir", "w", "", "WorkingDirectory of the service") + + RootCmd.AddCommand(createCmd) +} diff --git a/main.go b/main.go new file mode 100644 index 0000000..d3b14e1 --- /dev/null +++ b/main.go @@ -0,0 +1,23 @@ +package main + +import ( + "os" + + "github.com/spf13/cobra" +) + +var ( + RootCmd = &cobra.Command{ + Use: "service-generator", + Short: "service-generator creates systemd Unit files", + Long: "service-generator is a convenient little tool to create systemd Unit files", + SilenceErrors: false, + SilenceUsage: true, + } +) + +func main() { + if err := RootCmd.Execute(); err != nil { + os.Exit(-1) + } +}