-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
53 lines (41 loc) · 1.57 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/*
Copyright © 2024 Giulio Giannitrapani <[email protected]>
*/
package main
import (
"advent-of-code/twentyfour"
"advent-of-code/twentythree"
"os"
"github.com/spf13/cobra"
)
// rootCmd represents the base command when called without any subcommands
var rootCmd = &cobra.Command{
Use: "advent-of-code",
Short: "My solutions for Advent of Code",
Long: `Advent of Code is an Advent calendar of small programming puzzles for a variety
of skill sets and skill levels that can be solved in any programming language you like.
You can find out more about the Advent of Code at https://adventofcode.com/`,
}
func main() {
// rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.advent-of-code.yaml)")
rootCmd.AddCommand(twentythree.TwentythreeCmd)
rootCmd.AddCommand(twentyfour.TwentyfourCmd)
defaultHelpTemplate := rootCmd.HelpTemplate()
rootCmd.SetHelpTemplate(helpTemplate)
twentythree.TwentythreeCmd.SetHelpTemplate(defaultHelpTemplate)
err := rootCmd.Execute()
if err != nil {
os.Exit(1)
}
}
const helpTemplate = `{{with (or .Long .Short)}}{{. | trimTrailingWhitespaces}}{{end}}
Usage:{{if .Runnable}}
{{.UseLine}}{{end}}{{if .HasAvailableSubCommands}}
{{.CommandPath}} [command]{{end}}
Years Commands:{{range .Commands}}{{if and (ne .Name "help") (ne .Name "completion")}}
{{rpad .Name .NamePadding }} {{.Short}}{{end}}{{end}}
Others Commands:{{range .Commands}}{{if or (eq .Name "help") (eq .Name "completion")}}
{{rpad .Name .NamePadding }} {{.Short}}{{end}}{{end}}
Flags:
{{.LocalFlags.FlagUsages | trimTrailingWhitespaces}}
`