diff --git a/cmd/enbas/main.go b/cmd/enbas/main.go index 2b0b364..814abfa 100644 --- a/cmd/enbas/main.go +++ b/cmd/enbas/main.go @@ -46,29 +46,30 @@ func main() { func run() error { commandSummaries := map[string]string{ - commandLogin: "login to an account on GoToSocial", - commandVersion: "print the application's version and build information", - commandShow: "print details about a specified resource", - commandSwitch: "perform a switch operation (e.g. switch logged in accounts)", - commandCreate: "create a specific resource", - commandDelete: "delete a specific resource", - commandEdit: "edit a specific resource", - commandWhoami: "print the account that you are currently logged in to", - commandAdd: "add a resource to another resource", - commandRemove: "remove a resource from another resource", - commandFollow: "follow a resource (e.g. an account)", - commandUnfollow: "unfollow a resource (e.g. an account)", - commandBlock: "block a resource (e.g. an account)", - commandUnblock: "unblock a resource (e.g. an account)", + commandLogin: "Login to an account on GoToSocial", + commandVersion: "Print the application's version and build information", + commandShow: "Print details about a specified resource", + commandSwitch: "Perform a switch operation (e.g. switch logged in accounts)", + commandCreate: "Create a specific resource", + commandDelete: "Delete a specific resource", + commandEdit: "Edit a specific resource", + commandWhoami: "Print the account that you are currently logged in to", + commandAdd: "Add a resource to another resource", + commandRemove: "Remove a resource from another resource", + commandFollow: "Follow a resource (e.g. an account)", + commandUnfollow: "Unfollow a resource (e.g. an account)", + commandBlock: "Block a resource (e.g. an account)", + commandUnblock: "Unblock a resource (e.g. an account)", } topLevelFlags := executor.TopLevelFlags{ ConfigDir: "", NoColor: nil, + Pager: "", } - flag.StringVar(&topLevelFlags.ConfigDir, "config-dir", "", "specify your config directory") - flag.BoolFunc("no-color", "disable ANSI colour output when displaying text on screen", func(value string) error { + flag.StringVar(&topLevelFlags.ConfigDir, "config-dir", "", "Specify your config directory") + flag.BoolFunc("no-color", "Disable ANSI colour output when displaying text on screen", func(value string) error { boolVal, err := strconv.ParseBool(value) if err != nil { return fmt.Errorf("unable to parse %q as a boolean: %w", value, err) @@ -79,6 +80,7 @@ func run() error { return nil }) + flag.StringVar(&topLevelFlags.Pager, "pager", "", "Specify your preferred pager to page through long outputs. This is disabled by default.") flag.Usage = usageFunc(commandSummaries) diff --git a/internal/executor/add.go b/internal/executor/add.go index d48e909..99946d7 100644 --- a/internal/executor/add.go +++ b/internal/executor/add.go @@ -32,12 +32,12 @@ func NewAddExecutor(tlf TopLevelFlags, name, summary string) *AddExecutor { topLevelFlags: tlf, } - addExe.StringVar(&addExe.resourceType, flagType, "", "specify the resource type to add (e.g. account, note)") - addExe.StringVar(&addExe.toResourceType, flagTo, "", "specify the target resource type to add to (e.g. list, account, etc)") - addExe.StringVar(&addExe.listID, flagListID, "", "the ID of the list to add to") - addExe.StringVar(&addExe.statusID, flagStatusID, "", "the ID of the status") - addExe.Var(&addExe.accountNames, flagAccountName, "the name of the account") - addExe.StringVar(&addExe.content, flagContent, "", "the content of the note") + addExe.StringVar(&addExe.resourceType, flagType, "", "Specify the resource type to add (e.g. account, note)") + addExe.StringVar(&addExe.toResourceType, flagTo, "", "Specify the target resource type to add to (e.g. list, account, etc)") + addExe.StringVar(&addExe.listID, flagListID, "", "The ID of the list to add to") + addExe.StringVar(&addExe.statusID, flagStatusID, "", "The ID of the status") + addExe.Var(&addExe.accountNames, flagAccountName, "The name of the account") + addExe.StringVar(&addExe.content, flagContent, "", "The content of the resource") addExe.Usage = commandUsageFunc(name, summary, addExe.FlagSet) diff --git a/internal/executor/block.go b/internal/executor/block.go index 89928c5..9ec2ade 100644 --- a/internal/executor/block.go +++ b/internal/executor/block.go @@ -28,8 +28,8 @@ func NewBlockExecutor(tlf TopLevelFlags, name, summary string, unblock bool) *Bl unblock: unblock, } - blockExe.StringVar(&blockExe.resourceType, flagType, "", "specify the type of resource to block or unblock") - blockExe.StringVar(&blockExe.accountName, flagAccountName, "", "specify the account name in full (username@domain)") + blockExe.StringVar(&blockExe.resourceType, flagType, "", "Specify the type of resource to block or unblock") + blockExe.StringVar(&blockExe.accountName, flagAccountName, "", "Specify the account name in full (username@domain)") blockExe.Usage = commandUsageFunc(name, summary, blockExe.FlagSet) diff --git a/internal/executor/create.go b/internal/executor/create.go index 84c2793..d05814c 100644 --- a/internal/executor/create.go +++ b/internal/executor/create.go @@ -41,21 +41,21 @@ func NewCreateExecutor(tlf TopLevelFlags, name, summary string) *CreateExecutor topLevelFlags: tlf, } - createExe.BoolVar(&createExe.boostable, flagEnableReposts, true, "specify if the status can be reposted/boosted by others") - createExe.BoolVar(&createExe.federated, flagEnableFederation, true, "specify if the status can be federated beyond the local timelines") - createExe.BoolVar(&createExe.likeable, flagEnableLikes, true, "specify if the status can be liked/favourited") - createExe.BoolVar(&createExe.replyable, flagEnableReplies, true, "specify if the status can be replied to") - createExe.StringVar(&createExe.content, flagContent, "", "the content of the status to create") - createExe.StringVar(&createExe.contentType, flagContentType, "plain", "the type that the contents should be parsed from (valid values are plain and markdown)") - createExe.StringVar(&createExe.fromFile, flagFromFile, "", "the file path where to read the contents from") - createExe.StringVar(&createExe.language, flagLanguage, "", "the ISO 639 language code for this status") - createExe.StringVar(&createExe.spoilerText, flagSpoilerText, "", "the text to display as the status' warning or subject") - createExe.StringVar(&createExe.visibility, flagVisibility, "", "the visibility of the posted status") - createExe.StringVar(&createExe.resourceType, flagType, "", "specify the type of resource to create") - createExe.StringVar(&createExe.listTitle, flagListTitle, "", "specify the title of the list") - createExe.StringVar(&createExe.listRepliesPolicy, flagListRepliesPolicy, "list", "specify the policy of the replies for this list (valid values are followed, list and none)") + createExe.BoolVar(&createExe.boostable, flagEnableReposts, true, "Specify if the status can be reposted/boosted by others") + createExe.BoolVar(&createExe.federated, flagEnableFederation, true, "Specify if the status can be federated beyond the local timelines") + createExe.BoolVar(&createExe.likeable, flagEnableLikes, true, "Specify if the status can be liked/favourited") + createExe.BoolVar(&createExe.replyable, flagEnableReplies, true, "Specify if the status can be replied to") + createExe.StringVar(&createExe.content, flagContent, "", "The content of the status to create") + createExe.StringVar(&createExe.contentType, flagContentType, "plain", "The type that the contents should be parsed from (valid values are plain and markdown)") + createExe.StringVar(&createExe.fromFile, flagFromFile, "", "The file path where to read the contents from") + createExe.StringVar(&createExe.language, flagLanguage, "", "The ISO 639 language code for this status") + createExe.StringVar(&createExe.spoilerText, flagSpoilerText, "", "The text to display as the status' warning or subject") + createExe.StringVar(&createExe.visibility, flagVisibility, "", "The visibility of the posted status") + createExe.StringVar(&createExe.resourceType, flagType, "", "Specify the type of resource to create") + createExe.StringVar(&createExe.listTitle, flagListTitle, "", "Specify the title of the list") + createExe.StringVar(&createExe.listRepliesPolicy, flagListRepliesPolicy, "list", "Specify the policy of the replies for this list (valid values are followed, list and none)") - createExe.BoolFunc(flagSensitive, "specify if the status should be marked as sensitive", func(value string) error { + createExe.BoolFunc(flagSensitive, "Specify if the status should be marked as sensitive", func(value string) error { boolVal, err := strconv.ParseBool(value) if err != nil { return fmt.Errorf("unable to parse %q as a boolean value: %w", value, err) @@ -116,7 +116,7 @@ func (c *CreateExecutor) createList(gtsClient *client.Client) error { } fmt.Println("Successfully created the following list:") - utilities.Display(list, *c.topLevelFlags.NoColor) + utilities.Display(list, *c.topLevelFlags.NoColor, c.topLevelFlags.Pager) return nil } @@ -197,7 +197,7 @@ func (c *CreateExecutor) createStatus(gtsClient *client.Client) error { } fmt.Println("Successfully created the following status:") - utilities.Display(status, *c.topLevelFlags.NoColor) + utilities.Display(status, *c.topLevelFlags.NoColor, c.topLevelFlags.Pager) return nil } diff --git a/internal/executor/delete.go b/internal/executor/delete.go index 2df8cdb..fec798d 100644 --- a/internal/executor/delete.go +++ b/internal/executor/delete.go @@ -25,8 +25,8 @@ func NewDeleteExecutor(tlf TopLevelFlags, name, summary string) *DeleteExecutor topLevelFlags: tlf, } - deleteExe.StringVar(&deleteExe.resourceType, flagType, "", "specify the type of resource to delete") - deleteExe.StringVar(&deleteExe.listID, flagListID, "", "specify the ID of the list to delete") + deleteExe.StringVar(&deleteExe.resourceType, flagType, "", "Specify the type of resource to delete") + deleteExe.StringVar(&deleteExe.listID, flagListID, "", "Specify the ID of the list to delete") deleteExe.Usage = commandUsageFunc(name, summary, deleteExe.FlagSet) diff --git a/internal/executor/edit.go b/internal/executor/edit.go index f21b233..620a3ca 100644 --- a/internal/executor/edit.go +++ b/internal/executor/edit.go @@ -29,10 +29,10 @@ func NewEditExecutor(tlf TopLevelFlags, name, summary string) *EditExecutor { topLevelFlags: tlf, } - editExe.StringVar(&editExe.resourceType, flagType, "", "specify the type of resource to update") - editExe.StringVar(&editExe.listID, flagListID, "", "specify the ID of the list to update") - editExe.StringVar(&editExe.listTitle, flagListTitle, "", "specify the title of the list") - editExe.StringVar(&editExe.listRepliesPolicy, flagListRepliesPolicy, "", "specify the policy of the replies for this list (valid values are followed, list and none)") + editExe.StringVar(&editExe.resourceType, flagType, "", "Specify the type of resource to update") + editExe.StringVar(&editExe.listID, flagListID, "", "Specify the ID of the list to update") + editExe.StringVar(&editExe.listTitle, flagListTitle, "", "Specify the title of the list") + editExe.StringVar(&editExe.listRepliesPolicy, flagListRepliesPolicy, "", "Specify the policy of the replies for this list (valid values are followed, list and none)") editExe.Usage = commandUsageFunc(name, summary, editExe.FlagSet) @@ -90,7 +90,7 @@ func (e *EditExecutor) editList(gtsClient *client.Client) error { } fmt.Println("Successfully updated the list.") - utilities.Display(updatedList, *e.topLevelFlags.NoColor) + utilities.Display(updatedList, *e.topLevelFlags.NoColor, e.topLevelFlags.Pager) return nil } diff --git a/internal/executor/flags.go b/internal/executor/flags.go index f617224..c38e03f 100644 --- a/internal/executor/flags.go +++ b/internal/executor/flags.go @@ -23,4 +23,5 @@ func (a *AccountNames) Set(value string) error { type TopLevelFlags struct { ConfigDir string NoColor *bool + Pager string } diff --git a/internal/executor/follow.go b/internal/executor/follow.go index ea421dc..cce9e42 100644 --- a/internal/executor/follow.go +++ b/internal/executor/follow.go @@ -29,10 +29,10 @@ func NewFollowExecutor(tlf TopLevelFlags, name, summary string, unfollow bool) * topLevelFlags: tlf, } - command.StringVar(&command.resourceType, flagType, "", "specify the type of resource to follow") - command.StringVar(&command.accountName, flagAccountName, "", "specify the account name in full (username@domain)") - command.BoolVar(&command.showReposts, flagShowReposts, true, "show reposts from the account you want to follow") - command.BoolVar(&command.notify, flagNotify, false, "get notifications when the account you want to follow posts a status") + command.StringVar(&command.resourceType, flagType, "", "Specify the type of resource to follow") + command.StringVar(&command.accountName, flagAccountName, "", "Specify the account name in full (username@domain)") + command.BoolVar(&command.showReposts, flagShowReposts, true, "Show reposts from the account you want to follow") + command.BoolVar(&command.notify, flagNotify, false, "Get notifications when the account you want to follow posts a status") command.Usage = commandUsageFunc(name, summary, command.FlagSet) diff --git a/internal/executor/login.go b/internal/executor/login.go index 821a49c..79af662 100644 --- a/internal/executor/login.go +++ b/internal/executor/login.go @@ -28,7 +28,7 @@ func NewLoginExecutor(tlf TopLevelFlags, name, summary string) *LoginExecutor { instance: "", } - command.StringVar(&command.instance, flagInstance, "", "specify the instance that you want to login to.") + command.StringVar(&command.instance, flagInstance, "", "Specify the instance that you want to login to.") command.Usage = commandUsageFunc(name, summary, command.FlagSet) diff --git a/internal/executor/remove.go b/internal/executor/remove.go index 0018ad0..53cdf40 100644 --- a/internal/executor/remove.go +++ b/internal/executor/remove.go @@ -31,11 +31,11 @@ func NewRemoveExecutor(tlf TopLevelFlags, name, summary string) *RemoveExecutor topLevelFlags: tlf, } - removeExe.StringVar(&removeExe.resourceType, flagType, "", "specify the resource type to remove (e.g. account, note)") - removeExe.StringVar(&removeExe.fromResourceType, flagFrom, "", "specify the resource type to remove from (e.g. list, account, etc)") - removeExe.StringVar(&removeExe.listID, flagListID, "", "the ID of the list to remove from") - removeExe.StringVar(&removeExe.statusID, flagStatusID, "", "the ID of the status") - removeExe.Var(&removeExe.accountNames, flagAccountName, "the name of the account to remove from the resource") + removeExe.StringVar(&removeExe.resourceType, flagType, "", "Specify the resource type to remove (e.g. account, note)") + removeExe.StringVar(&removeExe.fromResourceType, flagFrom, "", "Specify the resource type to remove from (e.g. list, account, etc)") + removeExe.StringVar(&removeExe.listID, flagListID, "", "The ID of the list to remove from") + removeExe.StringVar(&removeExe.statusID, flagStatusID, "", "The ID of the status") + removeExe.Var(&removeExe.accountNames, flagAccountName, "The name of the account to remove from the resource") removeExe.Usage = commandUsageFunc(name, summary, removeExe.FlagSet) diff --git a/internal/executor/show.go b/internal/executor/show.go index 10a7069..cbacb47 100644 --- a/internal/executor/show.go +++ b/internal/executor/show.go @@ -35,17 +35,17 @@ func NewShowExecutor(tlf TopLevelFlags, name, summary string) *ShowExecutor { topLevelFlags: tlf, } - showExe.BoolVar(&showExe.myAccount, flagMyAccount, false, "set to true to lookup your account") - showExe.BoolVar(&showExe.skipAccountRelationship, flagSkipRelationship, false, "set to true to skip showing your relationship to the specified account") - showExe.BoolVar(&showExe.showUserPreferences, flagShowPreferences, false, "show your preferences") - showExe.BoolVar(&showExe.showInBrowser, flagBrowser, false, "set to true to view in the browser") - showExe.StringVar(&showExe.resourceType, flagType, "", "specify the type of resource to display") - showExe.StringVar(&showExe.accountName, flagAccountName, "", "specify the account name in full (username@domain)") - showExe.StringVar(&showExe.statusID, flagStatusID, "", "specify the ID of the status to display") - showExe.StringVar(&showExe.timelineCategory, flagTimelineCategory, model.TimelineCategoryHome, "specify the timeline category to view") - showExe.StringVar(&showExe.listID, flagListID, "", "specify the ID of the list to display") - showExe.StringVar(&showExe.tag, flagTag, "", "specify the name of the tag to use") - showExe.IntVar(&showExe.limit, flagLimit, 20, "specify the limit of items to display") + showExe.BoolVar(&showExe.myAccount, flagMyAccount, false, "Set to true to lookup your account") + showExe.BoolVar(&showExe.skipAccountRelationship, flagSkipRelationship, false, "Set to true to skip showing your relationship to the specified account") + showExe.BoolVar(&showExe.showUserPreferences, flagShowPreferences, false, "Show your preferences") + showExe.BoolVar(&showExe.showInBrowser, flagBrowser, false, "Set to true to view in the browser") + showExe.StringVar(&showExe.resourceType, flagType, "", "Specify the type of resource to display") + showExe.StringVar(&showExe.accountName, flagAccountName, "", "Specify the account name in full (username@domain)") + showExe.StringVar(&showExe.statusID, flagStatusID, "", "Specify the ID of the status to display") + showExe.StringVar(&showExe.timelineCategory, flagTimelineCategory, model.TimelineCategoryHome, "Specify the timeline category to view") + showExe.StringVar(&showExe.listID, flagListID, "", "Specify the ID of the list to display") + showExe.StringVar(&showExe.tag, flagTag, "", "Specify the name of the tag to use") + showExe.IntVar(&showExe.limit, flagLimit, 20, "Specify the limit of items to display") showExe.Usage = commandUsageFunc(name, summary, showExe.FlagSet) @@ -90,7 +90,7 @@ func (s *ShowExecutor) showInstance(gtsClient *client.Client) error { return fmt.Errorf("unable to retrieve the instance details: %w", err) } - utilities.Display(instance, *s.topLevelFlags.NoColor) + utilities.Display(instance, *s.topLevelFlags.NoColor, s.topLevelFlags.Pager) return nil } @@ -123,7 +123,7 @@ func (s *ShowExecutor) showAccount(gtsClient *client.Client) error { return nil } - utilities.Display(account, *s.topLevelFlags.NoColor) + utilities.Display(account, *s.topLevelFlags.NoColor, s.topLevelFlags.Pager) if !s.myAccount && !s.skipAccountRelationship { relationship, err := gtsClient.GetAccountRelationship(account.ID) @@ -131,7 +131,7 @@ func (s *ShowExecutor) showAccount(gtsClient *client.Client) error { return fmt.Errorf("unable to retrieve the relationship to this account: %w", err) } - utilities.Display(relationship, *s.topLevelFlags.NoColor) + utilities.Display(relationship, *s.topLevelFlags.NoColor, s.topLevelFlags.Pager) } if s.myAccount && s.showUserPreferences { @@ -140,7 +140,7 @@ func (s *ShowExecutor) showAccount(gtsClient *client.Client) error { return fmt.Errorf("unable to retrieve the user preferences: %w", err) } - utilities.Display(preferences, *s.topLevelFlags.NoColor) + utilities.Display(preferences, *s.topLevelFlags.NoColor, s.topLevelFlags.Pager) } return nil @@ -162,7 +162,7 @@ func (s *ShowExecutor) showStatus(gtsClient *client.Client) error { return nil } - utilities.Display(status, *s.topLevelFlags.NoColor) + utilities.Display(status, *s.topLevelFlags.NoColor, s.topLevelFlags.Pager) return nil } @@ -211,7 +211,7 @@ func (s *ShowExecutor) showTimeline(gtsClient *client.Client) error { return nil } - utilities.Display(timeline, *s.topLevelFlags.NoColor) + utilities.Display(timeline, *s.topLevelFlags.NoColor, s.topLevelFlags.Pager) return nil } @@ -240,7 +240,7 @@ func (s *ShowExecutor) showList(gtsClient *client.Client) error { list.Accounts = accountMap } - utilities.Display(list, *s.topLevelFlags.NoColor) + utilities.Display(list, *s.topLevelFlags.NoColor, s.topLevelFlags.Pager) return nil } @@ -257,7 +257,7 @@ func (s *ShowExecutor) showLists(gtsClient *client.Client) error { return nil } - utilities.Display(lists, *s.topLevelFlags.NoColor) + utilities.Display(lists, *s.topLevelFlags.NoColor, s.topLevelFlags.Pager) return nil } @@ -274,7 +274,7 @@ func (s *ShowExecutor) showFollowers(gtsClient *client.Client) error { } if len(followers.Accounts) > 0 { - utilities.Display(followers, *s.topLevelFlags.NoColor) + utilities.Display(followers, *s.topLevelFlags.NoColor, s.topLevelFlags.Pager) } else { fmt.Println("There are no followers for this account or the list is hidden.") } @@ -294,7 +294,7 @@ func (s *ShowExecutor) showFollowing(gtsClient *client.Client) error { } if len(following.Accounts) > 0 { - utilities.Display(following, *s.topLevelFlags.NoColor) + utilities.Display(following, *s.topLevelFlags.NoColor, s.topLevelFlags.Pager) } else { fmt.Println("This account is not following anyone or the list is hidden.") } @@ -309,7 +309,7 @@ func (s *ShowExecutor) showBlocked(gtsClient *client.Client) error { } if len(blocked.Accounts) > 0 { - utilities.Display(blocked, *s.topLevelFlags.NoColor) + utilities.Display(blocked, *s.topLevelFlags.NoColor, s.topLevelFlags.Pager) } else { fmt.Println("You have no blocked accounts.") } @@ -324,7 +324,7 @@ func (s *ShowExecutor) showBookmarks(gtsClient *client.Client) error { } if len(bookmarks.Statuses) > 0 { - utilities.Display(bookmarks, *s.topLevelFlags.NoColor) + utilities.Display(bookmarks, *s.topLevelFlags.NoColor, s.topLevelFlags.Pager) } else { fmt.Println("You have no bookmarks.") } @@ -339,7 +339,7 @@ func (s *ShowExecutor) showLiked(gtsClient *client.Client) error { } if len(liked.Statuses) > 0 { - utilities.Display(liked, *s.topLevelFlags.NoColor) + utilities.Display(liked, *s.topLevelFlags.NoColor, s.topLevelFlags.Pager) } else { fmt.Printf("You have no %s statuses.\n", s.resourceType) } diff --git a/internal/executor/switch.go b/internal/executor/switch.go index 5c85ac6..142be3f 100644 --- a/internal/executor/switch.go +++ b/internal/executor/switch.go @@ -25,8 +25,8 @@ func NewSwitchExecutor(tlf TopLevelFlags, name, summary string) *SwitchExecutor topLevelFlags: tlf, } - switchExe.StringVar(&switchExe.toResourceType, flagTo, "", "the account to switch to") - switchExe.StringVar(&switchExe.accountName, flagAccountName, "", "the name of the account to switch to") + switchExe.StringVar(&switchExe.toResourceType, flagTo, "", "The account to switch to") + switchExe.StringVar(&switchExe.accountName, flagAccountName, "", "The name of the account to switch to") switchExe.Usage = commandUsageFunc(name, summary, switchExe.FlagSet) diff --git a/internal/executor/version.go b/internal/executor/version.go index 7ae1892..3689e89 100644 --- a/internal/executor/version.go +++ b/internal/executor/version.go @@ -30,7 +30,7 @@ func NewVersionExecutor(name, summary, binaryVersion, buildTime, goVersion, gitC showFullVersion: false, } - command.BoolVar(&command.showFullVersion, "full", false, "prints the full build information") + command.BoolVar(&command.showFullVersion, "Full", false, "prints the full build information") command.Usage = commandUsageFunc(name, summary, command.FlagSet) diff --git a/internal/model/status.go b/internal/model/status.go index a534215..09befcd 100644 --- a/internal/model/status.go +++ b/internal/model/status.go @@ -209,7 +209,7 @@ type StatusList struct { func (s StatusList) Display(noColor bool) string { var builder strings.Builder - separator := "────────────────────────────────────────────────────────────────────────────────" + separator := strings.Repeat("─", 80) builder.WriteString(utilities.HeaderFormat(noColor, s.Name) + "\n") diff --git a/internal/utilities/displayer.go b/internal/utilities/displayer.go index 198337a..a595c2a 100644 --- a/internal/utilities/displayer.go +++ b/internal/utilities/displayer.go @@ -4,12 +4,50 @@ package utilities -import "os" +import ( + "fmt" + "os" + "os/exec" + "strings" +) type Displayer interface { Display(noColor bool) string } -func Display(d Displayer, noColor bool) { - os.Stdout.WriteString(d.Display(noColor) + "\n") +func Display(displayer Displayer, noColor bool, pagerCommand string) { + if pagerCommand == "" { + os.Stdout.WriteString(displayer.Display(noColor) + "\n") + + return + } + + split := strings.Split(pagerCommand, " ") + + pager := new(exec.Cmd) + + if len(split) == 1 { + pager = exec.Command(split[0]) //nolint:gosec + } else { + pager = exec.Command(split[0], split[1:]...) //nolint:gosec + } + + pipe, err := pager.StdinPipe() + if err != nil { + os.Stdout.WriteString(displayer.Display(noColor) + "\n") + + return + } + + pager.Stdout = os.Stdout + pager.Stderr = os.Stderr + + _ = pager.Start() + + defer func() { + _ = pipe.Close() + _ = pager.Wait() + }() + + fmt.Fprintln(pipe, displayer.Display(noColor)+"\n") }