Skip to content

Commit

Permalink
Add --help and --version flags
Browse files Browse the repository at this point in the history
  • Loading branch information
muesli authored and meowgorithm committed Dec 9, 2021
1 parent 58f7622 commit 485aa55
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Soft Serve
<a href="https://github.com/charmbracelet/soft-serve/actions"><img src="https://github.com/charmbracelet/soft-serve/workflows/build/badge.svg" alt="Build Status"></a>
</p>

A tasty, self-hosted Git server for the command line. 🍦
A tasty, self-hostable Git server for the command line. 🍦

<img src="https://stuff.charm.sh/soft-serve/soft-serve-cli-demo.gif" width="700" alt="Soft Serve screencast">

Expand Down
29 changes: 29 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,42 @@
package main

import (
"flag"
"fmt"
"log"
"os"

"github.com/charmbracelet/soft/config"
"github.com/charmbracelet/soft/server"
)

var (
Version = ""
CommitSHA = ""

version = flag.Bool("version", false, "display version")
)

func main() {
flag.Parse()

if *version {
if len(CommitSHA) > 7 {
CommitSHA = CommitSHA[:7]
}
if Version == "" {
Version = "(built from source)"
}

fmt.Printf("Soft Serve %s", Version)
if len(CommitSHA) > 0 {
fmt.Printf(" (%s)", CommitSHA)
}

fmt.Println()
os.Exit(0)
}

cfg := config.DefaultConfig()
s := server.NewServer(cfg)
log.Printf("Starting SSH server on %s:%d\n", cfg.Host, cfg.Port)
Expand Down

0 comments on commit 485aa55

Please sign in to comment.