Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add --version, completions, manpages #29

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
dist
sequin
*.gif
completions/
manpages/
9 changes: 1 addition & 8 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,4 @@
version: 2
includes:
- from_url:
url: charmbracelet/meta/main/goreleaser-simple.yaml
variables:
main: "."
description: "Human-readable ANSI sequences."
github_url: "https://github.com/charmbracelet/sequin"
maintainer: "Carlos A Becker <[email protected]>"
brew_commit_author_name: "Carlos A Becker"
brew_commit_author_email: "[email protected]"
url: charmbracelet/meta/main/goreleaser-sequin.yaml
4 changes: 4 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ require (
github.com/charmbracelet/x/exp/golden v0.0.0-20241029204245-3ef5e7b1ea37
github.com/charmbracelet/x/term v0.2.1
github.com/charmbracelet/x/xpty v0.1.1
github.com/muesli/mango-cobra v1.2.0
github.com/muesli/roff v0.1.0
github.com/spf13/cobra v1.8.1
github.com/stretchr/testify v1.9.0
)
Expand All @@ -23,6 +25,8 @@ require (
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
github.com/muesli/cancelreader v0.2.2 // indirect
github.com/muesli/mango v0.1.0 // indirect
github.com/muesli/mango-pflag v0.1.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/rivo/uniseg v0.4.7 // indirect
github.com/spf13/pflag v1.0.5 // indirect
Expand Down
8 changes: 8 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69
github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
github.com/muesli/cancelreader v0.2.2 h1:3I4Kt4BQjOR54NavqnDogx/MIoWBFa0StPA8ELUXHmA=
github.com/muesli/cancelreader v0.2.2/go.mod h1:3XuTXfFS2VjM+HTLZY9Ak0l6eUKfijIfMUZ4EgX0QYo=
github.com/muesli/mango v0.1.0 h1:DZQK45d2gGbql1arsYA4vfg4d7I9Hfx5rX/GCmzsAvI=
github.com/muesli/mango v0.1.0/go.mod h1:5XFpbC8jY5UUv89YQciiXNlbi+iJgt29VDC5xbzrLL4=
github.com/muesli/mango-cobra v1.2.0 h1:DQvjzAM0PMZr85Iv9LIMaYISpTOliMEg+uMFtNbYvWg=
github.com/muesli/mango-cobra v1.2.0/go.mod h1:vMJL54QytZAJhCT13LPVDfkvCUJ5/4jNUKF/8NC2UjA=
github.com/muesli/mango-pflag v0.1.0 h1:UADqbYgpUyRoBja3g6LUL+3LErjpsOwaC9ywvBWe7Sg=
github.com/muesli/mango-pflag v0.1.0/go.mod h1:YEQomTxaCUp8PrbhFh10UfbhbQrM/xJ4i2PB8VTLLW0=
github.com/muesli/roff v0.1.0 h1:YD0lalCotmYuF5HhZliKWlIx7IEhiXeSfq7hNjFqGF8=
github.com/muesli/roff v0.1.0/go.mod h1:pjAHQM9hdUUwm/krAfrLGgJkXJ+YuhtsfZ42kieB2Ig=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
Expand Down
29 changes: 29 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
"github.com/charmbracelet/lipgloss/v2"
"github.com/charmbracelet/x/ansi"
"github.com/charmbracelet/x/ansi/parser"
mcobra "github.com/muesli/mango-cobra"
"github.com/muesli/roff"
"github.com/spf13/cobra"
)

Expand All @@ -23,6 +25,9 @@
var (
buf bytes.Buffer
raw bool

// Version as provided by goreleaser.
Version = ""
)

func main() {
Expand Down Expand Up @@ -52,13 +57,37 @@
in, err = executeCommand(cmd.Context(), args)
}
if err != nil {
//nolint:wrapcheck

Check failure on line 60 in main.go

View workflow job for this annotation

GitHub Actions / lint / lint-soft (ubuntu-latest)

directive `//nolint:wrapcheck` is unused for linter "wrapcheck" (nolintlint)

Check failure on line 60 in main.go

View workflow job for this annotation

GitHub Actions / lint / lint-soft (macos-latest)

directive `//nolint:wrapcheck` is unused for linter "wrapcheck" (nolintlint)

Check failure on line 60 in main.go

View workflow job for this annotation

GitHub Actions / lint / lint-soft (macos-latest)

directive `//nolint:wrapcheck` is unused for linter "wrapcheck" (nolintlint)

Check failure on line 60 in main.go

View workflow job for this annotation

GitHub Actions / lint / lint-soft (ubuntu-latest)

directive `//nolint:wrapcheck` is unused for linter "wrapcheck" (nolintlint)

Check failure on line 60 in main.go

View workflow job for this annotation

GitHub Actions / lint / lint-soft (windows-latest)

directive `//nolint:wrapcheck` is unused for linter "wrapcheck" (nolintlint)

Check failure on line 60 in main.go

View workflow job for this annotation

GitHub Actions / lint / lint-soft (windows-latest)

directive `//nolint:wrapcheck` is unused for linter "wrapcheck" (nolintlint)
return err
}
return process(w, in)
},
}
root.Flags().BoolVarP(&raw, "raw", "r", false, "raw mode (no explanation)")

root.InitDefaultCompletionCmd()
root.AddCommand(&cobra.Command{
Use: "man",
Short: "Generates manpages",
SilenceUsage: true,
DisableFlagsInUseLine: true,
Hidden: true,
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {

Check failure on line 76 in main.go

View workflow job for this annotation

GitHub Actions / lint / lint (ubuntu-latest)

unused-parameter: parameter 'cmd' seems to be unused, consider removing or renaming it as _ (revive)

Check failure on line 76 in main.go

View workflow job for this annotation

GitHub Actions / lint / lint (ubuntu-latest)

unused-parameter: parameter 'cmd' seems to be unused, consider removing or renaming it as _ (revive)
manPage, err := mcobra.NewManPage(1, root.Root())
if err != nil {
return err

Check failure on line 79 in main.go

View workflow job for this annotation

GitHub Actions / lint / lint-soft (ubuntu-latest)

error returned from external package is unwrapped: sig: func github.com/muesli/mango-cobra.NewManPage(section uint, c *github.com/spf13/cobra.Command) (*github.com/muesli/mango.ManPage, error) (wrapcheck)

Check failure on line 79 in main.go

View workflow job for this annotation

GitHub Actions / lint / lint-soft (macos-latest)

error returned from external package is unwrapped: sig: func github.com/muesli/mango-cobra.NewManPage(section uint, c *github.com/spf13/cobra.Command) (*github.com/muesli/mango.ManPage, error) (wrapcheck)

Check failure on line 79 in main.go

View workflow job for this annotation

GitHub Actions / lint / lint-soft (macos-latest)

error returned from external package is unwrapped: sig: func github.com/muesli/mango-cobra.NewManPage(section uint, c *github.com/spf13/cobra.Command) (*github.com/muesli/mango.ManPage, error) (wrapcheck)

Check failure on line 79 in main.go

View workflow job for this annotation

GitHub Actions / lint / lint-soft (ubuntu-latest)

error returned from external package is unwrapped: sig: func github.com/muesli/mango-cobra.NewManPage(section uint, c *github.com/spf13/cobra.Command) (*github.com/muesli/mango.ManPage, error) (wrapcheck)

Check failure on line 79 in main.go

View workflow job for this annotation

GitHub Actions / lint / lint-soft (windows-latest)

error returned from external package is unwrapped: sig: func github.com/muesli/mango-cobra.NewManPage(section uint, c *github.com/spf13/cobra.Command) (*github.com/muesli/mango.ManPage, error) (wrapcheck)

Check failure on line 79 in main.go

View workflow job for this annotation

GitHub Actions / lint / lint-soft (windows-latest)

error returned from external package is unwrapped: sig: func github.com/muesli/mango-cobra.NewManPage(section uint, c *github.com/spf13/cobra.Command) (*github.com/muesli/mango.ManPage, error) (wrapcheck)
}

_, err = fmt.Fprint(os.Stdout, manPage.Build(roff.NewDocument()))
return err

Check failure on line 83 in main.go

View workflow job for this annotation

GitHub Actions / lint / lint-soft (ubuntu-latest)

error returned from external package is unwrapped: sig: func fmt.Fprint(w io.Writer, a ...any) (n int, err error) (wrapcheck)

Check failure on line 83 in main.go

View workflow job for this annotation

GitHub Actions / lint / lint-soft (macos-latest)

error returned from external package is unwrapped: sig: func fmt.Fprint(w io.Writer, a ...any) (n int, err error) (wrapcheck)

Check failure on line 83 in main.go

View workflow job for this annotation

GitHub Actions / lint / lint-soft (macos-latest)

error returned from external package is unwrapped: sig: func fmt.Fprint(w io.Writer, a ...any) (n int, err error) (wrapcheck)

Check failure on line 83 in main.go

View workflow job for this annotation

GitHub Actions / lint / lint-soft (ubuntu-latest)

error returned from external package is unwrapped: sig: func fmt.Fprint(w io.Writer, a ...any) (n int, err error) (wrapcheck)

Check failure on line 83 in main.go

View workflow job for this annotation

GitHub Actions / lint / lint-soft (windows-latest)

error returned from external package is unwrapped: sig: func fmt.Fprint(w io.Writer, a ...any) (n int, err error) (wrapcheck)

Check failure on line 83 in main.go

View workflow job for this annotation

GitHub Actions / lint / lint-soft (windows-latest)

error returned from external package is unwrapped: sig: func fmt.Fprint(w io.Writer, a ...any) (n int, err error) (wrapcheck)
},
})

if Version == "" {
Version = "unknown (built from source)"
}
root.Version = Version
return root
}

Expand Down
Loading