diff --git a/.gitignore b/.gitignore index 11424a6..f564d98 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ kef-virtual-hub bin +.task diff --git a/Taskfile.yaml b/Taskfile.yaml index bc62496..010a3a6 100644 --- a/Taskfile.yaml +++ b/Taskfile.yaml @@ -1,5 +1,5 @@ # This is a Taskfile. See https://taskfile.dev -# `brew install go-task` to install task runner +# `brew install go-task` to install task runner or `go install github.com/go-task/task/v3/cmd/task@latest` # `task --list` to list all tasks # `task ` to run a task @@ -8,13 +8,23 @@ version: '3' tasks: setup: desc: Install dependencies + run: once cmds: - brew install vhs build: desc: Build binaries cmds: - - go build -o bin/kefw2 cmd/kefw2/kefw2.go + - go build -ldflags="-X github.com/hilli/go-kef-w2/cmd.Version={{.GIT_COMMIT}}" -o bin/kefw2 cmd/kefw2/kefw2.go + alias: [b] + sources: + - cmd/kefw2/**/*.go + - kefw2/*.go + generates: + - bin/kefw2 + vars: + GIT_COMMIT: + sh: git log -n 1 --format=%h includes: docs: diff --git a/cmd/kefw2/cmd/root.go b/cmd/kefw2/cmd/root.go index 87d1bdc..b379d04 100644 --- a/cmd/kefw2/cmd/root.go +++ b/cmd/kefw2/cmd/root.go @@ -38,6 +38,7 @@ var ( speakers []kefw2.KEFSpeaker defaultSpeaker *kefw2.KEFSpeaker currentSpeaker *kefw2.KEFSpeaker + Version string ) // rootCmd represents the base command when called without any subcommands @@ -50,6 +51,14 @@ var rootCmd = &cobra.Command{ // Run: func(cmd *cobra.Command, args []string) { }, } +var VersionCmd = &cobra.Command{ + Use: "version", + Long: "Print the version number of kefw2", + Run: func(cmd *cobra.Command, args []string) { + log.Info("kefw2 version: ", Version) + }, +} + // Execute adds all child commands to the root command and sets flags appropriately. // This is called by main.main(). It only needs to happen once to the rootCmd. func Execute() { @@ -60,7 +69,7 @@ func Execute() { } func init() { - rootCmd.AddCommand(ConfigCmd) + rootCmd.AddCommand(ConfigCmd, VersionCmd) cobra.OnInitialize(initConfig) // Find home directory. diff --git a/docs/Taskfile.yaml b/docs/Taskfile.yaml index 79d5616..dab9f65 100644 --- a/docs/Taskfile.yaml +++ b/docs/Taskfile.yaml @@ -1,7 +1,11 @@ version: '3' tasks: record: - desc: Record kefw2.tape actions to docs/kefw2.gif (requires vhs) + desc: Record kefw2.tape actions to docs/kefw2.gif (requires vhs, Music.app and JXA) + platforms: [darwin] cmds: - rm -f ~/.config/kefw2/kefw2.yaml - - vhs kefw2.tape \ No newline at end of file + - vhs kefw2.tape + preconditions: + - test -f ../bin/kefw2 + - which vhs \ No newline at end of file