Skip to content

Commit

Permalink
Add verbose details to convert command
Browse files Browse the repository at this point in the history
  • Loading branch information
leighmacdonald committed Mar 12, 2024
1 parent 9f8ebf7 commit 30a3081
Showing 1 changed file with 20 additions and 7 deletions.
27 changes: 20 additions & 7 deletions cmd/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,19 @@ import (
"github.com/spf13/cobra"
)

func printAllConversions(sid steamid.SteamID) {
fmt.Printf(`Steam: %s
Steam3: %s
Steam32: %d
Steam64: %d`, sid.Steam(false), sid.Steam3(), sid.AccountID, sid.Int64()) //nolint:forbidigo
func printAllConversions(sid steamid.SteamID, verbose bool) {
suffix := ""
if verbose {
suffix = fmt.Sprintf(`Instance: %s
Account Type: %s
Universe: %s`, sid.Instance.String(), sid.AccountType.String(), sid.Universe.String())
}
fmt.Printf(`Steam: %s
Steam3: %s
Steam32: %d
Steam64: %d
%s`, sid.Steam(false), sid.Steam3(), sid.AccountID, sid.Int64(), suffix) //nolint:forbidigo

}

// convertCmd parses and prints out the steam id formats for the input steamid.
Expand All @@ -33,6 +41,11 @@ All formats are parsed from the file and duplicates are removed`,
os.Exit(1)
}

verbose := false

if verbFlag := cmd.Flag("verbose"); verbFlag != nil {
verbose = verbFlag.Changed
}
idType := ""

if typeVal := cmd.Flag("format"); typeVal != nil {
Expand All @@ -41,7 +54,7 @@ All formats are parsed from the file and duplicates are removed`,

switch idType {
case "":
printAllConversions(sid)
printAllConversions(sid, verbose)
case "steam":
fallthrough
case "steam2":
Expand All @@ -64,7 +77,7 @@ All formats are parsed from the file and duplicates are removed`,

func init() {
rootCmd.AddCommand(convertCmd)

convertCmd.Flags().BoolP("verbose", "v", false, "Show verbose steam details")
convertCmd.Flags().StringP("format", "f", "",
"Output format to use. Applied to each ID. (steam, steam3, steam32, steam64)")
}

0 comments on commit 30a3081

Please sign in to comment.