feat: added context flag to make dev easier

needed until we have proper server subcommand system
This commit is contained in:
Roxie Gibson 2021-07-17 09:29:25 +01:00
parent b9e06f2310
commit 6c748922b4
Signed by untrusted user: roxxers
GPG Key ID: 5D0140EDEE123F4D
2 changed files with 32 additions and 0 deletions

View File

@ -39,6 +39,7 @@ func RunApp(version, commit string) {
BranchFlag,
NoPromptFlag,
DebugFlag,
ContextFlag,
},
}

View File

@ -1,6 +1,9 @@
package cli
import (
"os"
"github.com/olekukonko/tablewriter"
"github.com/urfave/cli/v2"
)
@ -176,3 +179,31 @@ var TypeFlag = &cli.StringFlag{
Value: "",
Destination: &Type,
}
var Context string
var ContextFlag = &cli.StringFlag{
Name: "context",
Value: "",
Aliases: []string{"c"},
Destination: &Context,
}
func createTable(columns []string) *tablewriter.Table {
table := tablewriter.NewWriter(os.Stdout)
table.SetHeader(columns)
// Settings to create very bare tab padded table
table.SetAutoWrapText(false)
table.SetAutoFormatHeaders(true)
table.SetHeaderAlignment(tablewriter.ALIGN_LEFT)
table.SetAlignment(tablewriter.ALIGN_LEFT)
table.SetCenterSeparator("")
table.SetColumnSeparator("")
table.SetRowSeparator("")
table.SetHeaderLine(false)
table.SetBorder(false)
table.SetTablePadding("\t") // pad with tabs
table.SetNoWhiteSpace(true)
table.SetColWidth(1)
return table
}