Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Do not require value for version call #352

Merged
merged 2 commits into from
Jul 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,13 @@ func getCommitInfo() string {
return commit
}

func printVersion() {
fmt.Printf("immich-go %s, commit %s, built at %s\n", version, getCommitInfo(), date)
}

func main() {
var err error

fmt.Printf("immich-go %s, commit %s, built at %s\n", version, getCommitInfo(), date)

// Create a context with cancel function to gracefully handle Ctrl+C events
ctx, cancel := context.WithCancel(context.Background())

Expand Down Expand Up @@ -86,8 +88,8 @@ func Run(ctx context.Context) error {
Banner: ui.NewBanner(version, commit, date),
}
fs := flag.NewFlagSet("main", flag.ExitOnError)
fs.Func("version", "Get immich-go version", func(s string) error {
fmt.Println("immich-go", version)
fs.BoolFunc("version", "Get immich-go version", func(s string) error {
printVersion()
os.Exit(0)
return nil
})
Expand All @@ -100,6 +102,8 @@ func Run(ctx context.Context) error {
app.Log.Error(err.Error())
return err
}

printVersion()
fmt.Println(app.Banner.String())

if len(fs.Args()) == 0 {
Expand Down