Initial work-in-progress

This commit is contained in:
Christian Muehlhaeuser 2018-03-09 22:23:05 +01:00
parent 69f9b3691f
commit 3307087412
No known key found for this signature in database
GPG Key ID: BA4CF857DD4117E9
2 changed files with 60 additions and 0 deletions

37
createcmd.go Normal file
View File

@ -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 <executable>",
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)
}

23
main.go Normal file
View File

@ -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)
}
}