Compare commits
No commits in common. "e898a1ded53df56f513ea8a0f5887f4992a98eda" and "89e53bcc9fd534f5d31a28a27c385637d3f403d4" have entirely different histories.
e898a1ded5
...
89e53bcc9f
12 changed files with 170 additions and 169 deletions
|
@ -129,14 +129,6 @@ func {{ $execute_command_function_name }}(
|
||||||
exe.Var(&exe.{{ flagFieldName $flag }}, {{ printf "%q" $flag.Flag }}, {{ getFlagDescription $flag.Flag | printf "%q" }})
|
exe.Var(&exe.{{ flagFieldName $flag }}, {{ printf "%q" $flag.Flag }}, {{ getFlagDescription $flag.Flag | printf "%q" }})
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
{{ print "" }}
|
|
||||||
{{ print "" }}
|
|
||||||
// Parse the remaining arguments.
|
|
||||||
if err := exe.Parse(args); err != nil {
|
|
||||||
printer.NewPrinter(noColor, "", 0).PrintFailure("({{ $name }}) flag parsing error: " + err.Error() + ".")
|
|
||||||
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
{{- if $command.UseConfig -}}
|
{{- if $command.UseConfig -}}
|
||||||
{{ print "" }}
|
{{ print "" }}
|
||||||
{{ print "" }}
|
{{ print "" }}
|
||||||
|
@ -163,6 +155,13 @@ func {{ $execute_command_function_name }}(
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
{{ print "" }}
|
{{ print "" }}
|
||||||
{{ print "" }}
|
{{ print "" }}
|
||||||
|
// Parse the remaining arguments.
|
||||||
|
if err := exe.Parse(args); err != nil {
|
||||||
|
exe.printer.PrintFailure("({{ $name }}) flag parsing error: " + err.Error() + ".")
|
||||||
|
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
// Run the executor.
|
// Run the executor.
|
||||||
if err := exe.Execute(); err != nil {
|
if err := exe.Execute(); err != nil {
|
||||||
exe.printer.PrintFailure("({{ $name }}) execution error: " + err.Error() + ".")
|
exe.printer.PrintFailure("({{ $name }}) execution error: " + err.Error() + ".")
|
||||||
|
|
|
@ -10,13 +10,12 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"codeflow.dananglin.me.uk/apollo/enbas/internal"
|
||||||
"codeflow.dananglin.me.uk/apollo/enbas/internal/config"
|
"codeflow.dananglin.me.uk/apollo/enbas/internal/config"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
applicationJSON string = "application/json; charset=utf-8"
|
applicationJSON string = "application/json; charset=utf-8"
|
||||||
redirectURI string = "urn:ietf:wg:oauth:2.0:oob"
|
|
||||||
userAgent string = "Enbas/0.2.0"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type Client struct {
|
type Client struct {
|
||||||
|
@ -43,7 +42,7 @@ func NewClient(authentication config.Credentials) *Client {
|
||||||
gtsClient := Client{
|
gtsClient := Client{
|
||||||
Authentication: authentication,
|
Authentication: authentication,
|
||||||
HTTPClient: httpClient,
|
HTTPClient: httpClient,
|
||||||
UserAgent: userAgent,
|
UserAgent: internal.UserAgent,
|
||||||
Timeout: 5 * time.Second,
|
Timeout: 5 * time.Second,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,7 +51,7 @@ func NewClient(authentication config.Credentials) *Client {
|
||||||
|
|
||||||
func (g *Client) AuthCodeURL() string {
|
func (g *Client) AuthCodeURL() string {
|
||||||
format := "%s/oauth/authorize?client_id=%s&redirect_uri=%s&response_type=code"
|
format := "%s/oauth/authorize?client_id=%s&redirect_uri=%s&response_type=code"
|
||||||
escapedRedirectURI := url.QueryEscape(redirectURI)
|
escapedRedirectURI := url.QueryEscape(internal.RedirectURI)
|
||||||
|
|
||||||
return fmt.Sprintf(
|
return fmt.Sprintf(
|
||||||
format,
|
format,
|
||||||
|
|
|
@ -6,7 +6,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"codeflow.dananglin.me.uk/apollo/enbas/internal/info"
|
"codeflow.dananglin.me.uk/apollo/enbas/internal"
|
||||||
"codeflow.dananglin.me.uk/apollo/enbas/internal/model"
|
"codeflow.dananglin.me.uk/apollo/enbas/internal/model"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -19,10 +19,10 @@ type registerRequest struct {
|
||||||
|
|
||||||
func (g *Client) Register() error {
|
func (g *Client) Register() error {
|
||||||
registerParams := registerRequest{
|
registerParams := registerRequest{
|
||||||
ClientName: info.ApplicationName,
|
ClientName: internal.ApplicationName,
|
||||||
RedirectUris: redirectURI,
|
RedirectUris: internal.RedirectURI,
|
||||||
Scopes: "read write",
|
Scopes: "read write",
|
||||||
Website: info.ApplicationWebsite,
|
Website: internal.ApplicationWebsite,
|
||||||
}
|
}
|
||||||
|
|
||||||
data, err := json.Marshal(registerParams)
|
data, err := json.Marshal(registerParams)
|
||||||
|
|
|
@ -5,6 +5,8 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
|
"codeflow.dananglin.me.uk/apollo/enbas/internal"
|
||||||
)
|
)
|
||||||
|
|
||||||
type tokenRequest struct {
|
type tokenRequest struct {
|
||||||
|
@ -24,7 +26,7 @@ type tokenResponse struct {
|
||||||
|
|
||||||
func (g *Client) UpdateToken(code string) error {
|
func (g *Client) UpdateToken(code string) error {
|
||||||
tokenReq := tokenRequest{
|
tokenReq := tokenRequest{
|
||||||
RedirectURI: redirectURI,
|
RedirectURI: internal.RedirectURI,
|
||||||
ClientID: g.Authentication.ClientID,
|
ClientID: g.Authentication.ClientID,
|
||||||
ClientSecret: g.Authentication.ClientSecret,
|
ClientSecret: g.Authentication.ClientSecret,
|
||||||
GrantType: "authorization_code",
|
GrantType: "authorization_code",
|
||||||
|
|
|
@ -106,13 +106,6 @@ func ExecuteAcceptCommand(
|
||||||
exe.Var(&exe.accountName, "account-name", "The name of the account")
|
exe.Var(&exe.accountName, "account-name", "The name of the account")
|
||||||
exe.StringVar(&exe.resourceType, "type", "", "The type of resource you want to action on (e.g. account, status)")
|
exe.StringVar(&exe.resourceType, "type", "", "The type of resource you want to action on (e.g. account, status)")
|
||||||
|
|
||||||
// Parse the remaining arguments.
|
|
||||||
if err := exe.Parse(args); err != nil {
|
|
||||||
printer.NewPrinter(noColor, "", 0).PrintFailure("(accept) flag parsing error: " + err.Error() + ".")
|
|
||||||
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Load the configuration from file.
|
// Load the configuration from file.
|
||||||
exeConfig, err := config.NewConfigFromFile(exe.configDir)
|
exeConfig, err := config.NewConfigFromFile(exe.configDir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -129,6 +122,13 @@ func ExecuteAcceptCommand(
|
||||||
exe.config.LineWrapMaxWidth,
|
exe.config.LineWrapMaxWidth,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Parse the remaining arguments.
|
||||||
|
if err := exe.Parse(args); err != nil {
|
||||||
|
exe.printer.PrintFailure("(accept) flag parsing error: " + err.Error() + ".")
|
||||||
|
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
// Run the executor.
|
// Run the executor.
|
||||||
if err := exe.Execute(); err != nil {
|
if err := exe.Execute(); err != nil {
|
||||||
exe.printer.PrintFailure("(accept) execution error: " + err.Error() + ".")
|
exe.printer.PrintFailure("(accept) execution error: " + err.Error() + ".")
|
||||||
|
@ -179,13 +179,6 @@ func ExecuteAddCommand(
|
||||||
exe.StringVar(&exe.resourceType, "type", "", "The type of resource you want to action on (e.g. account, status)")
|
exe.StringVar(&exe.resourceType, "type", "", "The type of resource you want to action on (e.g. account, status)")
|
||||||
exe.Var(&exe.votes, "vote", "Add a vote to an option in a poll")
|
exe.Var(&exe.votes, "vote", "Add a vote to an option in a poll")
|
||||||
|
|
||||||
// Parse the remaining arguments.
|
|
||||||
if err := exe.Parse(args); err != nil {
|
|
||||||
printer.NewPrinter(noColor, "", 0).PrintFailure("(add) flag parsing error: " + err.Error() + ".")
|
|
||||||
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Load the configuration from file.
|
// Load the configuration from file.
|
||||||
exeConfig, err := config.NewConfigFromFile(exe.configDir)
|
exeConfig, err := config.NewConfigFromFile(exe.configDir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -202,6 +195,13 @@ func ExecuteAddCommand(
|
||||||
exe.config.LineWrapMaxWidth,
|
exe.config.LineWrapMaxWidth,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Parse the remaining arguments.
|
||||||
|
if err := exe.Parse(args); err != nil {
|
||||||
|
exe.printer.PrintFailure("(add) flag parsing error: " + err.Error() + ".")
|
||||||
|
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
// Run the executor.
|
// Run the executor.
|
||||||
if err := exe.Execute(); err != nil {
|
if err := exe.Execute(); err != nil {
|
||||||
exe.printer.PrintFailure("(add) execution error: " + err.Error() + ".")
|
exe.printer.PrintFailure("(add) execution error: " + err.Error() + ".")
|
||||||
|
@ -241,13 +241,6 @@ func ExecuteBlockCommand(
|
||||||
exe.Var(&exe.accountName, "account-name", "The name of the account")
|
exe.Var(&exe.accountName, "account-name", "The name of the account")
|
||||||
exe.StringVar(&exe.resourceType, "type", "", "The type of resource you want to action on (e.g. account, status)")
|
exe.StringVar(&exe.resourceType, "type", "", "The type of resource you want to action on (e.g. account, status)")
|
||||||
|
|
||||||
// Parse the remaining arguments.
|
|
||||||
if err := exe.Parse(args); err != nil {
|
|
||||||
printer.NewPrinter(noColor, "", 0).PrintFailure("(block) flag parsing error: " + err.Error() + ".")
|
|
||||||
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Load the configuration from file.
|
// Load the configuration from file.
|
||||||
exeConfig, err := config.NewConfigFromFile(exe.configDir)
|
exeConfig, err := config.NewConfigFromFile(exe.configDir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -264,6 +257,13 @@ func ExecuteBlockCommand(
|
||||||
exe.config.LineWrapMaxWidth,
|
exe.config.LineWrapMaxWidth,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Parse the remaining arguments.
|
||||||
|
if err := exe.Parse(args); err != nil {
|
||||||
|
exe.printer.PrintFailure("(block) flag parsing error: " + err.Error() + ".")
|
||||||
|
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
// Run the executor.
|
// Run the executor.
|
||||||
if err := exe.Execute(); err != nil {
|
if err := exe.Execute(); err != nil {
|
||||||
exe.printer.PrintFailure("(block) execution error: " + err.Error() + ".")
|
exe.printer.PrintFailure("(block) execution error: " + err.Error() + ".")
|
||||||
|
@ -351,13 +351,6 @@ func ExecuteCreateCommand(
|
||||||
exe.StringVar(&exe.resourceType, "type", "", "The type of resource you want to action on (e.g. account, status)")
|
exe.StringVar(&exe.resourceType, "type", "", "The type of resource you want to action on (e.g. account, status)")
|
||||||
exe.StringVar(&exe.visibility, "visibility", "", "The visibility of the posted status")
|
exe.StringVar(&exe.visibility, "visibility", "", "The visibility of the posted status")
|
||||||
|
|
||||||
// Parse the remaining arguments.
|
|
||||||
if err := exe.Parse(args); err != nil {
|
|
||||||
printer.NewPrinter(noColor, "", 0).PrintFailure("(create) flag parsing error: " + err.Error() + ".")
|
|
||||||
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Load the configuration from file.
|
// Load the configuration from file.
|
||||||
exeConfig, err := config.NewConfigFromFile(exe.configDir)
|
exeConfig, err := config.NewConfigFromFile(exe.configDir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -374,6 +367,13 @@ func ExecuteCreateCommand(
|
||||||
exe.config.LineWrapMaxWidth,
|
exe.config.LineWrapMaxWidth,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Parse the remaining arguments.
|
||||||
|
if err := exe.Parse(args); err != nil {
|
||||||
|
exe.printer.PrintFailure("(create) flag parsing error: " + err.Error() + ".")
|
||||||
|
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
// Run the executor.
|
// Run the executor.
|
||||||
if err := exe.Execute(); err != nil {
|
if err := exe.Execute(); err != nil {
|
||||||
exe.printer.PrintFailure("(create) execution error: " + err.Error() + ".")
|
exe.printer.PrintFailure("(create) execution error: " + err.Error() + ".")
|
||||||
|
@ -416,13 +416,6 @@ func ExecuteDeleteCommand(
|
||||||
exe.StringVar(&exe.statusID, "status-id", "", "The ID of the status")
|
exe.StringVar(&exe.statusID, "status-id", "", "The ID of the status")
|
||||||
exe.StringVar(&exe.resourceType, "type", "", "The type of resource you want to action on (e.g. account, status)")
|
exe.StringVar(&exe.resourceType, "type", "", "The type of resource you want to action on (e.g. account, status)")
|
||||||
|
|
||||||
// Parse the remaining arguments.
|
|
||||||
if err := exe.Parse(args); err != nil {
|
|
||||||
printer.NewPrinter(noColor, "", 0).PrintFailure("(delete) flag parsing error: " + err.Error() + ".")
|
|
||||||
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Load the configuration from file.
|
// Load the configuration from file.
|
||||||
exeConfig, err := config.NewConfigFromFile(exe.configDir)
|
exeConfig, err := config.NewConfigFromFile(exe.configDir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -439,6 +432,13 @@ func ExecuteDeleteCommand(
|
||||||
exe.config.LineWrapMaxWidth,
|
exe.config.LineWrapMaxWidth,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Parse the remaining arguments.
|
||||||
|
if err := exe.Parse(args); err != nil {
|
||||||
|
exe.printer.PrintFailure("(delete) flag parsing error: " + err.Error() + ".")
|
||||||
|
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
// Run the executor.
|
// Run the executor.
|
||||||
if err := exe.Execute(); err != nil {
|
if err := exe.Execute(); err != nil {
|
||||||
exe.printer.PrintFailure("(delete) execution error: " + err.Error() + ".")
|
exe.printer.PrintFailure("(delete) execution error: " + err.Error() + ".")
|
||||||
|
@ -490,13 +490,6 @@ func ExecuteEditCommand(
|
||||||
exe.Var(&exe.mediaFocusValues, "media-focus", "The focus of the media file")
|
exe.Var(&exe.mediaFocusValues, "media-focus", "The focus of the media file")
|
||||||
exe.StringVar(&exe.resourceType, "type", "", "The type of resource you want to action on (e.g. account, status)")
|
exe.StringVar(&exe.resourceType, "type", "", "The type of resource you want to action on (e.g. account, status)")
|
||||||
|
|
||||||
// Parse the remaining arguments.
|
|
||||||
if err := exe.Parse(args); err != nil {
|
|
||||||
printer.NewPrinter(noColor, "", 0).PrintFailure("(edit) flag parsing error: " + err.Error() + ".")
|
|
||||||
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Load the configuration from file.
|
// Load the configuration from file.
|
||||||
exeConfig, err := config.NewConfigFromFile(exe.configDir)
|
exeConfig, err := config.NewConfigFromFile(exe.configDir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -513,6 +506,13 @@ func ExecuteEditCommand(
|
||||||
exe.config.LineWrapMaxWidth,
|
exe.config.LineWrapMaxWidth,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Parse the remaining arguments.
|
||||||
|
if err := exe.Parse(args); err != nil {
|
||||||
|
exe.printer.PrintFailure("(edit) flag parsing error: " + err.Error() + ".")
|
||||||
|
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
// Run the executor.
|
// Run the executor.
|
||||||
if err := exe.Execute(); err != nil {
|
if err := exe.Execute(); err != nil {
|
||||||
exe.printer.PrintFailure("(edit) execution error: " + err.Error() + ".")
|
exe.printer.PrintFailure("(edit) execution error: " + err.Error() + ".")
|
||||||
|
@ -556,13 +556,6 @@ func ExecuteFollowCommand(
|
||||||
exe.BoolVar(&exe.showReposts, "show-reposts", true, "Show reposts from the account you want to follow")
|
exe.BoolVar(&exe.showReposts, "show-reposts", true, "Show reposts from the account you want to follow")
|
||||||
exe.StringVar(&exe.resourceType, "type", "", "The type of resource you want to action on (e.g. account, status)")
|
exe.StringVar(&exe.resourceType, "type", "", "The type of resource you want to action on (e.g. account, status)")
|
||||||
|
|
||||||
// Parse the remaining arguments.
|
|
||||||
if err := exe.Parse(args); err != nil {
|
|
||||||
printer.NewPrinter(noColor, "", 0).PrintFailure("(follow) flag parsing error: " + err.Error() + ".")
|
|
||||||
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Load the configuration from file.
|
// Load the configuration from file.
|
||||||
exeConfig, err := config.NewConfigFromFile(exe.configDir)
|
exeConfig, err := config.NewConfigFromFile(exe.configDir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -579,6 +572,13 @@ func ExecuteFollowCommand(
|
||||||
exe.config.LineWrapMaxWidth,
|
exe.config.LineWrapMaxWidth,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Parse the remaining arguments.
|
||||||
|
if err := exe.Parse(args); err != nil {
|
||||||
|
exe.printer.PrintFailure("(follow) flag parsing error: " + err.Error() + ".")
|
||||||
|
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
// Run the executor.
|
// Run the executor.
|
||||||
if err := exe.Execute(); err != nil {
|
if err := exe.Execute(); err != nil {
|
||||||
exe.printer.PrintFailure("(follow) execution error: " + err.Error() + ".")
|
exe.printer.PrintFailure("(follow) execution error: " + err.Error() + ".")
|
||||||
|
@ -612,16 +612,16 @@ func ExecuteInitCommand(
|
||||||
|
|
||||||
exe.Usage = usage.ExecutorUsageFunc("init", "Creates a new configuration file in the specified configuration directory", exe.FlagSet)
|
exe.Usage = usage.ExecutorUsageFunc("init", "Creates a new configuration file in the specified configuration directory", exe.FlagSet)
|
||||||
|
|
||||||
|
// Create the printer for the executor.
|
||||||
|
exe.printer = printer.NewPrinter(noColor, "", 0)
|
||||||
|
|
||||||
// Parse the remaining arguments.
|
// Parse the remaining arguments.
|
||||||
if err := exe.Parse(args); err != nil {
|
if err := exe.Parse(args); err != nil {
|
||||||
printer.NewPrinter(noColor, "", 0).PrintFailure("(init) flag parsing error: " + err.Error() + ".")
|
exe.printer.PrintFailure("(init) flag parsing error: " + err.Error() + ".")
|
||||||
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create the printer for the executor.
|
|
||||||
exe.printer = printer.NewPrinter(noColor, "", 0)
|
|
||||||
|
|
||||||
// Run the executor.
|
// Run the executor.
|
||||||
if err := exe.Execute(); err != nil {
|
if err := exe.Execute(); err != nil {
|
||||||
exe.printer.PrintFailure("(init) execution error: " + err.Error() + ".")
|
exe.printer.PrintFailure("(init) execution error: " + err.Error() + ".")
|
||||||
|
@ -658,13 +658,6 @@ func ExecuteLoginCommand(
|
||||||
|
|
||||||
exe.StringVar(&exe.instance, "instance", "", "The instance that you want to log into")
|
exe.StringVar(&exe.instance, "instance", "", "The instance that you want to log into")
|
||||||
|
|
||||||
// Parse the remaining arguments.
|
|
||||||
if err := exe.Parse(args); err != nil {
|
|
||||||
printer.NewPrinter(noColor, "", 0).PrintFailure("(login) flag parsing error: " + err.Error() + ".")
|
|
||||||
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Load the configuration from file.
|
// Load the configuration from file.
|
||||||
exeConfig, err := config.NewConfigFromFile(exe.configDir)
|
exeConfig, err := config.NewConfigFromFile(exe.configDir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -681,6 +674,13 @@ func ExecuteLoginCommand(
|
||||||
exe.config.LineWrapMaxWidth,
|
exe.config.LineWrapMaxWidth,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Parse the remaining arguments.
|
||||||
|
if err := exe.Parse(args); err != nil {
|
||||||
|
exe.printer.PrintFailure("(login) flag parsing error: " + err.Error() + ".")
|
||||||
|
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
// Run the executor.
|
// Run the executor.
|
||||||
if err := exe.Execute(); err != nil {
|
if err := exe.Execute(); err != nil {
|
||||||
exe.printer.PrintFailure("(login) execution error: " + err.Error() + ".")
|
exe.printer.PrintFailure("(login) execution error: " + err.Error() + ".")
|
||||||
|
@ -727,13 +727,6 @@ func ExecuteMuteCommand(
|
||||||
exe.StringVar(&exe.statusID, "status-id", "", "The ID of the status")
|
exe.StringVar(&exe.statusID, "status-id", "", "The ID of the status")
|
||||||
exe.StringVar(&exe.resourceType, "type", "", "The type of resource you want to action on (e.g. account, status)")
|
exe.StringVar(&exe.resourceType, "type", "", "The type of resource you want to action on (e.g. account, status)")
|
||||||
|
|
||||||
// Parse the remaining arguments.
|
|
||||||
if err := exe.Parse(args); err != nil {
|
|
||||||
printer.NewPrinter(noColor, "", 0).PrintFailure("(mute) flag parsing error: " + err.Error() + ".")
|
|
||||||
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Load the configuration from file.
|
// Load the configuration from file.
|
||||||
exeConfig, err := config.NewConfigFromFile(exe.configDir)
|
exeConfig, err := config.NewConfigFromFile(exe.configDir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -750,6 +743,13 @@ func ExecuteMuteCommand(
|
||||||
exe.config.LineWrapMaxWidth,
|
exe.config.LineWrapMaxWidth,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Parse the remaining arguments.
|
||||||
|
if err := exe.Parse(args); err != nil {
|
||||||
|
exe.printer.PrintFailure("(mute) flag parsing error: " + err.Error() + ".")
|
||||||
|
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
// Run the executor.
|
// Run the executor.
|
||||||
if err := exe.Execute(); err != nil {
|
if err := exe.Execute(); err != nil {
|
||||||
exe.printer.PrintFailure("(mute) execution error: " + err.Error() + ".")
|
exe.printer.PrintFailure("(mute) execution error: " + err.Error() + ".")
|
||||||
|
@ -789,13 +789,6 @@ func ExecuteRejectCommand(
|
||||||
exe.Var(&exe.accountName, "account-name", "The name of the account")
|
exe.Var(&exe.accountName, "account-name", "The name of the account")
|
||||||
exe.StringVar(&exe.resourceType, "type", "", "The type of resource you want to action on (e.g. account, status)")
|
exe.StringVar(&exe.resourceType, "type", "", "The type of resource you want to action on (e.g. account, status)")
|
||||||
|
|
||||||
// Parse the remaining arguments.
|
|
||||||
if err := exe.Parse(args); err != nil {
|
|
||||||
printer.NewPrinter(noColor, "", 0).PrintFailure("(reject) flag parsing error: " + err.Error() + ".")
|
|
||||||
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Load the configuration from file.
|
// Load the configuration from file.
|
||||||
exeConfig, err := config.NewConfigFromFile(exe.configDir)
|
exeConfig, err := config.NewConfigFromFile(exe.configDir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -812,6 +805,13 @@ func ExecuteRejectCommand(
|
||||||
exe.config.LineWrapMaxWidth,
|
exe.config.LineWrapMaxWidth,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Parse the remaining arguments.
|
||||||
|
if err := exe.Parse(args); err != nil {
|
||||||
|
exe.printer.PrintFailure("(reject) flag parsing error: " + err.Error() + ".")
|
||||||
|
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
// Run the executor.
|
// Run the executor.
|
||||||
if err := exe.Execute(); err != nil {
|
if err := exe.Execute(); err != nil {
|
||||||
exe.printer.PrintFailure("(reject) execution error: " + err.Error() + ".")
|
exe.printer.PrintFailure("(reject) execution error: " + err.Error() + ".")
|
||||||
|
@ -857,13 +857,6 @@ func ExecuteRemoveCommand(
|
||||||
exe.StringVar(&exe.statusID, "status-id", "", "The ID of the status")
|
exe.StringVar(&exe.statusID, "status-id", "", "The ID of the status")
|
||||||
exe.StringVar(&exe.resourceType, "type", "", "The type of resource you want to action on (e.g. account, status)")
|
exe.StringVar(&exe.resourceType, "type", "", "The type of resource you want to action on (e.g. account, status)")
|
||||||
|
|
||||||
// Parse the remaining arguments.
|
|
||||||
if err := exe.Parse(args); err != nil {
|
|
||||||
printer.NewPrinter(noColor, "", 0).PrintFailure("(remove) flag parsing error: " + err.Error() + ".")
|
|
||||||
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Load the configuration from file.
|
// Load the configuration from file.
|
||||||
exeConfig, err := config.NewConfigFromFile(exe.configDir)
|
exeConfig, err := config.NewConfigFromFile(exe.configDir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -880,6 +873,13 @@ func ExecuteRemoveCommand(
|
||||||
exe.config.LineWrapMaxWidth,
|
exe.config.LineWrapMaxWidth,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Parse the remaining arguments.
|
||||||
|
if err := exe.Parse(args); err != nil {
|
||||||
|
exe.printer.PrintFailure("(remove) flag parsing error: " + err.Error() + ".")
|
||||||
|
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
// Run the executor.
|
// Run the executor.
|
||||||
if err := exe.Execute(); err != nil {
|
if err := exe.Execute(); err != nil {
|
||||||
exe.printer.PrintFailure("(remove) execution error: " + err.Error() + ".")
|
exe.printer.PrintFailure("(remove) execution error: " + err.Error() + ".")
|
||||||
|
@ -958,13 +958,6 @@ func ExecuteShowCommand(
|
||||||
exe.StringVar(&exe.tag, "tag", "", "The name of the tag")
|
exe.StringVar(&exe.tag, "tag", "", "The name of the tag")
|
||||||
exe.StringVar(&exe.resourceType, "type", "", "The type of resource you want to action on (e.g. account, status)")
|
exe.StringVar(&exe.resourceType, "type", "", "The type of resource you want to action on (e.g. account, status)")
|
||||||
|
|
||||||
// Parse the remaining arguments.
|
|
||||||
if err := exe.Parse(args); err != nil {
|
|
||||||
printer.NewPrinter(noColor, "", 0).PrintFailure("(show) flag parsing error: " + err.Error() + ".")
|
|
||||||
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Load the configuration from file.
|
// Load the configuration from file.
|
||||||
exeConfig, err := config.NewConfigFromFile(exe.configDir)
|
exeConfig, err := config.NewConfigFromFile(exe.configDir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -981,6 +974,13 @@ func ExecuteShowCommand(
|
||||||
exe.config.LineWrapMaxWidth,
|
exe.config.LineWrapMaxWidth,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Parse the remaining arguments.
|
||||||
|
if err := exe.Parse(args); err != nil {
|
||||||
|
exe.printer.PrintFailure("(show) flag parsing error: " + err.Error() + ".")
|
||||||
|
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
// Run the executor.
|
// Run the executor.
|
||||||
if err := exe.Execute(); err != nil {
|
if err := exe.Execute(); err != nil {
|
||||||
exe.printer.PrintFailure("(show) execution error: " + err.Error() + ".")
|
exe.printer.PrintFailure("(show) execution error: " + err.Error() + ".")
|
||||||
|
@ -1020,13 +1020,6 @@ func ExecuteSwitchCommand(
|
||||||
exe.Var(&exe.accountName, "account-name", "The name of the account")
|
exe.Var(&exe.accountName, "account-name", "The name of the account")
|
||||||
exe.StringVar(&exe.to, "to", "", "The resource type to action the target resource to (e.g. status)")
|
exe.StringVar(&exe.to, "to", "", "The resource type to action the target resource to (e.g. status)")
|
||||||
|
|
||||||
// Parse the remaining arguments.
|
|
||||||
if err := exe.Parse(args); err != nil {
|
|
||||||
printer.NewPrinter(noColor, "", 0).PrintFailure("(switch) flag parsing error: " + err.Error() + ".")
|
|
||||||
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Load the configuration from file.
|
// Load the configuration from file.
|
||||||
exeConfig, err := config.NewConfigFromFile(exe.configDir)
|
exeConfig, err := config.NewConfigFromFile(exe.configDir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -1043,6 +1036,13 @@ func ExecuteSwitchCommand(
|
||||||
exe.config.LineWrapMaxWidth,
|
exe.config.LineWrapMaxWidth,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Parse the remaining arguments.
|
||||||
|
if err := exe.Parse(args); err != nil {
|
||||||
|
exe.printer.PrintFailure("(switch) flag parsing error: " + err.Error() + ".")
|
||||||
|
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
// Run the executor.
|
// Run the executor.
|
||||||
if err := exe.Execute(); err != nil {
|
if err := exe.Execute(); err != nil {
|
||||||
exe.printer.PrintFailure("(switch) execution error: " + err.Error() + ".")
|
exe.printer.PrintFailure("(switch) execution error: " + err.Error() + ".")
|
||||||
|
@ -1082,13 +1082,6 @@ func ExecuteUnblockCommand(
|
||||||
exe.Var(&exe.accountName, "account-name", "The name of the account")
|
exe.Var(&exe.accountName, "account-name", "The name of the account")
|
||||||
exe.StringVar(&exe.resourceType, "type", "", "The type of resource you want to action on (e.g. account, status)")
|
exe.StringVar(&exe.resourceType, "type", "", "The type of resource you want to action on (e.g. account, status)")
|
||||||
|
|
||||||
// Parse the remaining arguments.
|
|
||||||
if err := exe.Parse(args); err != nil {
|
|
||||||
printer.NewPrinter(noColor, "", 0).PrintFailure("(unblock) flag parsing error: " + err.Error() + ".")
|
|
||||||
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Load the configuration from file.
|
// Load the configuration from file.
|
||||||
exeConfig, err := config.NewConfigFromFile(exe.configDir)
|
exeConfig, err := config.NewConfigFromFile(exe.configDir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -1105,6 +1098,13 @@ func ExecuteUnblockCommand(
|
||||||
exe.config.LineWrapMaxWidth,
|
exe.config.LineWrapMaxWidth,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Parse the remaining arguments.
|
||||||
|
if err := exe.Parse(args); err != nil {
|
||||||
|
exe.printer.PrintFailure("(unblock) flag parsing error: " + err.Error() + ".")
|
||||||
|
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
// Run the executor.
|
// Run the executor.
|
||||||
if err := exe.Execute(); err != nil {
|
if err := exe.Execute(); err != nil {
|
||||||
exe.printer.PrintFailure("(unblock) execution error: " + err.Error() + ".")
|
exe.printer.PrintFailure("(unblock) execution error: " + err.Error() + ".")
|
||||||
|
@ -1144,13 +1144,6 @@ func ExecuteUnfollowCommand(
|
||||||
exe.Var(&exe.accountName, "account-name", "The name of the account")
|
exe.Var(&exe.accountName, "account-name", "The name of the account")
|
||||||
exe.StringVar(&exe.resourceType, "type", "", "The type of resource you want to action on (e.g. account, status)")
|
exe.StringVar(&exe.resourceType, "type", "", "The type of resource you want to action on (e.g. account, status)")
|
||||||
|
|
||||||
// Parse the remaining arguments.
|
|
||||||
if err := exe.Parse(args); err != nil {
|
|
||||||
printer.NewPrinter(noColor, "", 0).PrintFailure("(unfollow) flag parsing error: " + err.Error() + ".")
|
|
||||||
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Load the configuration from file.
|
// Load the configuration from file.
|
||||||
exeConfig, err := config.NewConfigFromFile(exe.configDir)
|
exeConfig, err := config.NewConfigFromFile(exe.configDir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -1167,6 +1160,13 @@ func ExecuteUnfollowCommand(
|
||||||
exe.config.LineWrapMaxWidth,
|
exe.config.LineWrapMaxWidth,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Parse the remaining arguments.
|
||||||
|
if err := exe.Parse(args); err != nil {
|
||||||
|
exe.printer.PrintFailure("(unfollow) flag parsing error: " + err.Error() + ".")
|
||||||
|
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
// Run the executor.
|
// Run the executor.
|
||||||
if err := exe.Execute(); err != nil {
|
if err := exe.Execute(); err != nil {
|
||||||
exe.printer.PrintFailure("(unfollow) execution error: " + err.Error() + ".")
|
exe.printer.PrintFailure("(unfollow) execution error: " + err.Error() + ".")
|
||||||
|
@ -1208,13 +1208,6 @@ func ExecuteUnmuteCommand(
|
||||||
exe.StringVar(&exe.statusID, "status-id", "", "The ID of the status")
|
exe.StringVar(&exe.statusID, "status-id", "", "The ID of the status")
|
||||||
exe.StringVar(&exe.resourceType, "type", "", "The type of resource you want to action on (e.g. account, status)")
|
exe.StringVar(&exe.resourceType, "type", "", "The type of resource you want to action on (e.g. account, status)")
|
||||||
|
|
||||||
// Parse the remaining arguments.
|
|
||||||
if err := exe.Parse(args); err != nil {
|
|
||||||
printer.NewPrinter(noColor, "", 0).PrintFailure("(unmute) flag parsing error: " + err.Error() + ".")
|
|
||||||
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Load the configuration from file.
|
// Load the configuration from file.
|
||||||
exeConfig, err := config.NewConfigFromFile(exe.configDir)
|
exeConfig, err := config.NewConfigFromFile(exe.configDir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -1231,6 +1224,13 @@ func ExecuteUnmuteCommand(
|
||||||
exe.config.LineWrapMaxWidth,
|
exe.config.LineWrapMaxWidth,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Parse the remaining arguments.
|
||||||
|
if err := exe.Parse(args); err != nil {
|
||||||
|
exe.printer.PrintFailure("(unmute) flag parsing error: " + err.Error() + ".")
|
||||||
|
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
// Run the executor.
|
// Run the executor.
|
||||||
if err := exe.Execute(); err != nil {
|
if err := exe.Execute(); err != nil {
|
||||||
exe.printer.PrintFailure("(unmute) execution error: " + err.Error() + ".")
|
exe.printer.PrintFailure("(unmute) execution error: " + err.Error() + ".")
|
||||||
|
@ -1267,16 +1267,16 @@ func ExecuteVersionCommand(
|
||||||
|
|
||||||
exe.BoolVar(&exe.full, "full", false, "Set to true to print the build information in full")
|
exe.BoolVar(&exe.full, "full", false, "Set to true to print the build information in full")
|
||||||
|
|
||||||
|
// Create the printer for the executor.
|
||||||
|
exe.printer = printer.NewPrinter(noColor, "", 0)
|
||||||
|
|
||||||
// Parse the remaining arguments.
|
// Parse the remaining arguments.
|
||||||
if err := exe.Parse(args); err != nil {
|
if err := exe.Parse(args); err != nil {
|
||||||
printer.NewPrinter(noColor, "", 0).PrintFailure("(version) flag parsing error: " + err.Error() + ".")
|
exe.printer.PrintFailure("(version) flag parsing error: " + err.Error() + ".")
|
||||||
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create the printer for the executor.
|
|
||||||
exe.printer = printer.NewPrinter(noColor, "", 0)
|
|
||||||
|
|
||||||
// Run the executor.
|
// Run the executor.
|
||||||
if err := exe.Execute(); err != nil {
|
if err := exe.Execute(); err != nil {
|
||||||
exe.printer.PrintFailure("(version) execution error: " + err.Error() + ".")
|
exe.printer.PrintFailure("(version) execution error: " + err.Error() + ".")
|
||||||
|
@ -1310,13 +1310,6 @@ func ExecuteWhoamiCommand(
|
||||||
|
|
||||||
exe.Usage = usage.ExecutorUsageFunc("whoami", "Prints the account that you are currently logged into", exe.FlagSet)
|
exe.Usage = usage.ExecutorUsageFunc("whoami", "Prints the account that you are currently logged into", exe.FlagSet)
|
||||||
|
|
||||||
// Parse the remaining arguments.
|
|
||||||
if err := exe.Parse(args); err != nil {
|
|
||||||
printer.NewPrinter(noColor, "", 0).PrintFailure("(whoami) flag parsing error: " + err.Error() + ".")
|
|
||||||
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Load the configuration from file.
|
// Load the configuration from file.
|
||||||
exeConfig, err := config.NewConfigFromFile(exe.configDir)
|
exeConfig, err := config.NewConfigFromFile(exe.configDir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -1333,6 +1326,13 @@ func ExecuteWhoamiCommand(
|
||||||
exe.config.LineWrapMaxWidth,
|
exe.config.LineWrapMaxWidth,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Parse the remaining arguments.
|
||||||
|
if err := exe.Parse(args); err != nil {
|
||||||
|
exe.printer.PrintFailure("(whoami) flag parsing error: " + err.Error() + ".")
|
||||||
|
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
// Run the executor.
|
// Run the executor.
|
||||||
if err := exe.Execute(); err != nil {
|
if err := exe.Execute(); err != nil {
|
||||||
exe.printer.PrintFailure("(whoami) execution error: " + err.Error() + ".")
|
exe.printer.PrintFailure("(whoami) execution error: " + err.Error() + ".")
|
||||||
|
|
8
internal/internal.go
Normal file
8
internal/internal.go
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
package internal
|
||||||
|
|
||||||
|
const (
|
||||||
|
ApplicationName = "enbas"
|
||||||
|
ApplicationWebsite = "https://codeflow.dananglin.me.uk/apollo/enbas"
|
||||||
|
RedirectURI = "urn:ietf:wg:oauth:2.0:oob"
|
||||||
|
UserAgent = "Enbas/0.0.0"
|
||||||
|
)
|
|
@ -4,12 +4,12 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"text/tabwriter"
|
"text/tabwriter"
|
||||||
|
|
||||||
"codeflow.dananglin.me.uk/apollo/enbas/internal/info"
|
"codeflow.dananglin.me.uk/apollo/enbas/internal/version"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (p Printer) PrintVersion(showFullVersion bool) {
|
func (p Printer) PrintVersion(showFullVersion bool) {
|
||||||
if !showFullVersion {
|
if !showFullVersion {
|
||||||
printToStdout("Enbas " + info.BinaryVersion + "\n")
|
printToStdout("Enbas " + version.BinaryVersion + "\n")
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -20,10 +20,10 @@ func (p Printer) PrintVersion(showFullVersion bool) {
|
||||||
|
|
||||||
tableWriter := tabwriter.NewWriter(&builder, 0, 4, 1, ' ', 0)
|
tableWriter := tabwriter.NewWriter(&builder, 0, 4, 1, ' ', 0)
|
||||||
|
|
||||||
_, _ = tableWriter.Write([]byte(p.fieldFormat("Version:") + "\t" + info.BinaryVersion + "\n"))
|
_, _ = tableWriter.Write([]byte(p.fieldFormat("Version:") + "\t" + version.BinaryVersion + "\n"))
|
||||||
_, _ = tableWriter.Write([]byte(p.fieldFormat("Git commit:") + "\t" + info.GitCommit + "\n"))
|
_, _ = tableWriter.Write([]byte(p.fieldFormat("Git commit:") + "\t" + version.GitCommit + "\n"))
|
||||||
_, _ = tableWriter.Write([]byte(p.fieldFormat("Go version:") + "\t" + info.GoVersion + "\n"))
|
_, _ = tableWriter.Write([]byte(p.fieldFormat("Go version:") + "\t" + version.GoVersion + "\n"))
|
||||||
_, _ = tableWriter.Write([]byte(p.fieldFormat("Build date:") + "\t" + info.BuildTime + "\n"))
|
_, _ = tableWriter.Write([]byte(p.fieldFormat("Build date:") + "\t" + version.BuildTime + "\n"))
|
||||||
|
|
||||||
tableWriter.Flush()
|
tableWriter.Flush()
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"text/tabwriter"
|
"text/tabwriter"
|
||||||
|
|
||||||
"codeflow.dananglin.me.uk/apollo/enbas/internal/info"
|
"codeflow.dananglin.me.uk/apollo/enbas/internal/version"
|
||||||
)
|
)
|
||||||
|
|
||||||
func AppUsageFunc() func() {
|
func AppUsageFunc() func() {
|
||||||
|
@ -24,13 +24,13 @@ func AppUsageFunc() func() {
|
||||||
return func() {
|
return func() {
|
||||||
var builder strings.Builder
|
var builder strings.Builder
|
||||||
|
|
||||||
builder.WriteString("SUMMARY:\n " + info.ApplicationName + " - A GoToSocial client for the terminal.\n\n")
|
builder.WriteString("SUMMARY:\n enbas - A GoToSocial client for the terminal.\n\n")
|
||||||
|
|
||||||
if info.BinaryVersion != "" {
|
if version.BinaryVersion != "" {
|
||||||
builder.WriteString("VERSION:\n " + info.BinaryVersion + "\n\n")
|
builder.WriteString("VERSION:\n " + version.BinaryVersion + "\n\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
builder.WriteString("USAGE:\n " + info.ApplicationName + " [flags]\n " + info.ApplicationName + " [flags] [command]\n\nCOMMANDS:")
|
builder.WriteString("USAGE:\n enbas [flags]\n enbas [flags] [command]\n\nCOMMANDS:")
|
||||||
|
|
||||||
tableWriter := tabwriter.NewWriter(&builder, 0, 8, 0, '\t', 0)
|
tableWriter := tabwriter.NewWriter(&builder, 0, 8, 0, '\t', 0)
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ func AppUsageFunc() func() {
|
||||||
fmt.Fprintf(&builder, "\n --%s\n %s", f.Name, f.Usage)
|
fmt.Fprintf(&builder, "\n --%s\n %s", f.Name, f.Usage)
|
||||||
})
|
})
|
||||||
|
|
||||||
builder.WriteString("\n\nUse \"" + info.ApplicationName + " [command] --help\" for more information about a command.\n")
|
builder.WriteString("\n\nUse \"enbas [command] --help\" for more information about a command.\n")
|
||||||
|
|
||||||
w := flag.CommandLine.Output()
|
w := flag.CommandLine.Output()
|
||||||
fmt.Fprint(w, builder.String())
|
fmt.Fprint(w, builder.String())
|
||||||
|
|
|
@ -4,8 +4,6 @@ import (
|
||||||
"flag"
|
"flag"
|
||||||
"slices"
|
"slices"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"codeflow.dananglin.me.uk/apollo/enbas/internal/info"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// ExecutorUsageFunc returns the function used to print a command's help page.
|
// ExecutorUsageFunc returns the function used to print a command's help page.
|
||||||
|
@ -16,7 +14,7 @@ func ExecutorUsageFunc(name, summary string, flagset *flag.FlagSet) func() {
|
||||||
builder.WriteString("SUMMARY:")
|
builder.WriteString("SUMMARY:")
|
||||||
builder.WriteString("\n " + name + " - " + summary)
|
builder.WriteString("\n " + name + " - " + summary)
|
||||||
builder.WriteString("\n\nUSAGE:")
|
builder.WriteString("\n\nUSAGE:")
|
||||||
builder.WriteString("\n " + info.ApplicationName + " " + name)
|
builder.WriteString("\n enbas " + name)
|
||||||
|
|
||||||
flagMap := make(map[string]string)
|
flagMap := make(map[string]string)
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
"codeflow.dananglin.me.uk/apollo/enbas/internal/info"
|
"codeflow.dananglin.me.uk/apollo/enbas/internal"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -24,7 +24,7 @@ func CalculateConfigDir(configDir string) (string, error) {
|
||||||
return "", fmt.Errorf("unable to get your default config diretory: %w", err)
|
return "", fmt.Errorf("unable to get your default config diretory: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return filepath.Join(configRoot, info.ApplicationName), nil
|
return filepath.Join(configRoot, internal.ApplicationName), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func CalculateMediaCacheDir(cacheRoot, instance string) (string, error) {
|
func CalculateMediaCacheDir(cacheRoot, instance string) (string, error) {
|
||||||
|
@ -57,7 +57,7 @@ func calculateCacheDir(cacheRoot, instance string) (string, error) {
|
||||||
return "", fmt.Errorf("unable to get your default cache directory: %w", err)
|
return "", fmt.Errorf("unable to get your default cache directory: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return filepath.Join(cacheRoot, info.ApplicationName, fqdn), nil
|
return filepath.Join(cacheRoot, internal.ApplicationName, fqdn), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func EnsureDirectory(dir string) error {
|
func EnsureDirectory(dir string) error {
|
||||||
|
|
|
@ -1,9 +1,4 @@
|
||||||
package info
|
package version
|
||||||
|
|
||||||
const (
|
|
||||||
ApplicationName string = "enbas"
|
|
||||||
ApplicationWebsite string = "https://codeflow.dananglin.me.uk/apollo/enbas"
|
|
||||||
)
|
|
||||||
|
|
||||||
var (
|
var (
|
||||||
BinaryVersion string //nolint:gochecknoglobals
|
BinaryVersion string //nolint:gochecknoglobals
|
|
@ -110,7 +110,7 @@ func Clean() error {
|
||||||
|
|
||||||
// ldflags returns the build flags.
|
// ldflags returns the build flags.
|
||||||
func ldflags() string {
|
func ldflags() string {
|
||||||
versionPackage := "codeflow.dananglin.me.uk/apollo/enbas/internal/info"
|
versionPackage := "codeflow.dananglin.me.uk/apollo/enbas/internal/version"
|
||||||
binaryVersionVar := versionPackage + "." + "BinaryVersion"
|
binaryVersionVar := versionPackage + "." + "BinaryVersion"
|
||||||
gitCommitVar := versionPackage + "." + "GitCommit"
|
gitCommitVar := versionPackage + "." + "GitCommit"
|
||||||
goVersionVar := versionPackage + "." + "GoVersion"
|
goVersionVar := versionPackage + "." + "GoVersion"
|
||||||
|
|
Loading…
Reference in a new issue