Skip to content

Commit

Permalink
Add a version command
Browse files Browse the repository at this point in the history
Adding a version string to the build, and as part of that we need a way
to handle default org values. Set to nil uuid if the default org is not
set.

Signed-off-by: Craig Tracey <craig@arctir.com>
  • Loading branch information
craigtracey committed Nov 24, 2024
1 parent d144770 commit 68e53eb
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
23 changes: 19 additions & 4 deletions commands/cli.go
Original file line number Diff line number Diff line change
@@ -1,20 +1,35 @@
package commands

import (
"fmt"
"os"
"path"

"github.com/arctir/flightdeck-cli/commands/common"
flightdeckclient "github.com/arctir/go-flightdeck/pkg/client"
)

var (
version = "dev"
commit = "none"
date = "unknown"
)

type Cli struct {
common.Globals

Auth AuthCommand `cmd:"auth"`
Create CreateCommand `cmd:"create"`
Get GetCommand `cmd:"get" predictor:"getPredictor"`
Delete DeleteCommand `cmd:"delete"`
Auth AuthCommand `cmd:"auth"`
Create CreateCommand `cmd:"create"`
Get GetCommand `cmd:"get" predictor:"getPredictor"`
Delete DeleteCommand `cmd:"delete"`
Version VersionCommand `cmd:"version"`
}

type VersionCommand struct{}

func (c VersionCommand) Run(parent *Cli, ctx *Context) error {
fmt.Printf("flightdeck %s, commit %s, built at %s", version, commit, date)
return nil
}

func (c *Cli) AfterApply(ctx *Context, globals *common.Globals) error {
Expand Down
2 changes: 1 addition & 1 deletion commands/common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package common
import "github.com/google/uuid"

type OrgFlags struct {
Org uuid.UUID `name:"org" short:"o" default:"${defaultOrg}" help:"ID of the organization."`
Org *uuid.UUID `name:"org" short:"o" optional:"" default:"${defaultOrg}" help:"ID of the organization."`
}

type PortalFlags struct {
Expand Down
4 changes: 4 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (

"github.com/alecthomas/kong"
"github.com/arctir/flightdeck-cli/commands"
"github.com/google/uuid"
)

const defaultAPIEndpoint = "https://api.arctir.cloud/v1"
Expand All @@ -26,6 +27,9 @@ func main() {
}

defaultOrg := os.Getenv("FLIGHTDECK_ORG")
if defaultOrg == "" {
defaultOrg = uuid.Nil.String()
}

cli := commands.Cli{}
commandContext := commands.Context{}
Expand Down

0 comments on commit 68e53eb

Please sign in to comment.