File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -16,6 +16,8 @@ builds:
1616 - arm64
1717 ldflags : |
1818 -X main.Version={{.Version}}
19+ -X main.Commit={{.Commit}}
20+ -X main.Date={{.Date}}
1921
2022archives :
2123 - name_template : >-
Original file line number Diff line number Diff line change @@ -2,16 +2,26 @@ package main
22
33import (
44 "flag"
5+ "fmt"
56 "log"
67 "os"
8+ "runtime"
79
810 "github.com/fgouteroux/sshot/pkg/playbook"
911 "github.com/fgouteroux/sshot/pkg/types"
1012)
1113
14+ // Build information set via ldflags
15+ var (
16+ Version = "dev"
17+ Commit = "none"
18+ Date = "unknown"
19+ )
20+
1221var execOptions types.ExecutionOptions
1322
1423func main () {
24+ version := flag .Bool ("version" , false , "Show version information" )
1525 dryRun := flag .Bool ("dry-run" , false , "Run in dry-run mode (don't execute commands)" )
1626 dryRunShort := flag .Bool ("n" , false , "Run in dry-run mode (shorthand)" )
1727 verbose := flag .Bool ("verbose" , false , "Enable verbose logging" )
@@ -25,6 +35,14 @@ func main() {
2535
2636 flag .Parse ()
2737
38+ if * version {
39+ fmt .Printf ("sshot %s\n " , Version )
40+ fmt .Printf (" commit: %s\n " , Commit )
41+ fmt .Printf (" built: %s\n " , Date )
42+ fmt .Printf (" go: %s\n " , runtime .Version ())
43+ os .Exit (0 )
44+ }
45+
2846 execOptions .DryRun = * dryRun || * dryRunShort
2947 execOptions .Verbose = * verbose || * verboseShort
3048 execOptions .Progress = * progress
You can’t perform that action at this time.
0 commit comments