-
Notifications
You must be signed in to change notification settings - Fork 122
Revert "Merge pull request #1028 from starius/downgrade-deps" #1031
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| version: "2" | ||
| run: | ||
| go: "1.23" | ||
| go: "1.24" | ||
|
|
||
| # timeout for analysis | ||
| timeout: 4m | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,152 @@ | ||
| package main | ||
|
|
||
| import ( | ||
| "context" | ||
| _ "embed" | ||
| "fmt" | ||
|
|
||
| docs "github.com/urfave/cli-docs/v3" | ||
| "github.com/urfave/cli/v3" | ||
| ) | ||
|
|
||
| //go:embed markdown_tabular.md.gotmpl | ||
| var markdownTabularDocTemplate string | ||
|
|
||
| // We have a copy of this template taken from | ||
| // https://github.com/urfave/cli-docs where we remove column | ||
| // "Environment variables" if it has no values. | ||
| // TODO: remove this when https://github.com/urfave/cli-docs/pull/15 | ||
| // is merged. | ||
| func init() { | ||
| docs.MarkdownTabularDocTemplate = markdownTabularDocTemplate | ||
| } | ||
|
|
||
| var printManCommand = &cli.Command{ | ||
| Name: "man", | ||
| Usage: "prints man file", | ||
| Description: "Prints documentation of loop CLI in man format", | ||
| Action: printMan, | ||
| Hidden: true, | ||
| } | ||
|
|
||
| func printMan(_ context.Context, cmd *cli.Command) error { | ||
| root := filterNestedHelpCommands(cmd.Root()) | ||
|
|
||
| const userCommandsSection = 1 | ||
| man, err := docs.ToManWithSection(root, userCommandsSection) | ||
| if err != nil { | ||
| return fmt.Errorf("failed to produce man: %w", err) | ||
| } | ||
|
|
||
| fmt.Println(man) | ||
|
|
||
| return nil | ||
| } | ||
|
|
||
| var printMarkdownCommand = &cli.Command{ | ||
| Name: "markdown", | ||
| Usage: "prints markdown file", | ||
| Description: "Prints documentation of loop CLI in markdown format", | ||
| Action: printMarkdown, | ||
| Hidden: true, | ||
| } | ||
|
|
||
| func printMarkdown(_ context.Context, cmd *cli.Command) error { | ||
| root := filterNestedHelpCommands(cmd.Root()) | ||
|
|
||
| md, err := docs.ToTabularMarkdown(root, "loop") | ||
| if err != nil { | ||
| return fmt.Errorf("failed to produce man: %w", err) | ||
| } | ||
|
|
||
| fmt.Println(md) | ||
|
|
||
| return nil | ||
| } | ||
|
|
||
| // filterNestedHelpCommands clones cmd, drops nested help commands, and normalises | ||
| // flag defaults so generated documentation avoids absolute paths. | ||
| func filterNestedHelpCommands(cmd *cli.Command) *cli.Command { | ||
| cloned := cloneCommand(cmd, 0) | ||
| overrideDocFlags(cloned) | ||
| return cloned | ||
| } | ||
|
|
||
| // cloneCommand clones the command, filtering out nested "help" subcommands. | ||
| func cloneCommand(cmd *cli.Command, depth int) *cli.Command { | ||
| if cmd == nil { | ||
| return nil | ||
| } | ||
|
|
||
| cloned := *cmd | ||
| if len(cmd.Commands) == 0 { | ||
| return &cloned | ||
| } | ||
|
|
||
| filtered := make([]*cli.Command, 0, len(cmd.Commands)) | ||
| for _, sub := range cmd.Commands { | ||
| if sub == nil { | ||
| continue | ||
| } | ||
| childDepth := depth + 1 | ||
|
|
||
| // TODO: remove when https://github.com/urfave/cli-docs/pull/16 | ||
| if childDepth > 0 && sub.Name == "help" { | ||
| continue | ||
| } | ||
|
|
||
| filtered = append(filtered, cloneCommand(sub, childDepth)) | ||
| } | ||
|
|
||
| cloned.Commands = filtered | ||
| return &cloned | ||
| } | ||
|
|
||
| // overrideDocFlags walks the command tree and replaces string flag defaults | ||
| // that leak user-specific filesystem paths, keeping generated docs stable. | ||
| func overrideDocFlags(cmd *cli.Command) { | ||
| if cmd == nil { | ||
| return | ||
| } | ||
|
|
||
| if len(cmd.Flags) > 0 { | ||
| clonedFlags := make([]cli.Flag, len(cmd.Flags)) | ||
| for i, fl := range cmd.Flags { | ||
| clonedFlags[i] = cloneFlagWithOverrides(fl) | ||
| } | ||
| cmd.Flags = clonedFlags | ||
| } | ||
|
|
||
| for _, sub := range cmd.Commands { | ||
| overrideDocFlags(sub) | ||
| } | ||
| } | ||
|
|
||
| // docFlagOverrides maps global flag names to the canonical values we want to | ||
| // show in documentation instead of user-specific absolute paths. | ||
| var docFlagOverrides = map[string]string{ | ||
| loopDirFlag.Name: "~/.loop", | ||
| tlsCertFlag.Name: "~/.loop/mainnet/tls.cert", | ||
| macaroonPathFlag.Name: "~/.loop/mainnet/loop.macaroon", | ||
| } | ||
|
|
||
| // cloneFlagWithOverrides returns a copy of flag with overridden default values | ||
| // when the flag participates in docFlagOverrides. Non-string flags are reused | ||
| // unchanged to minimise allocations. | ||
| func cloneFlagWithOverrides(flag cli.Flag) cli.Flag { | ||
| sf, ok := flag.(*cli.StringFlag) | ||
| if !ok { | ||
| return flag | ||
| } | ||
|
|
||
| value, ok := docFlagOverrides[sf.Name] | ||
| if !ok { | ||
| return flag | ||
| } | ||
|
|
||
| cloned := *sf | ||
| cloned.Value = value | ||
| cloned.DefaultText = value | ||
|
|
||
| return &cloned | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| {{ define "flags" }} | ||
| {{- $hasEnvVars := false -}} | ||
| {{- range . -}} | ||
| {{- if and (not $hasEnvVars) .EnvVars -}} | ||
| {{- $hasEnvVars = true -}} | ||
| {{- end -}} | ||
| {{- end }} | ||
| | Name | Description | Type | Default value {{ if $hasEnvVars }}| Environment variables {{ end }}| | ||
| |------|-------------|------|:-------------:{{ if $hasEnvVars }}|:---------------------:{{ end }}| | ||
| {{ range $flag := . -}} | ||
| {{- /**/ -}} | `{{ $flag.Name }}{{ if $flag.TakesValue }}="…"{{ end }}` {{ if $flag.Aliases }}(`{{ join $flag.Aliases "`, `" }}`) {{ end }} | ||
| {{- /**/ -}} | {{ $flag.Usage }} | ||
| {{- /**/ -}} | {{ $flag.Type }} | ||
| {{- /**/ -}} | {{ if $flag.Default }}`{{ $flag.Default }}`{{ end }} | ||
| {{- if $hasEnvVars -}} | ||
| {{- /**/ -}} | {{ if $flag.EnvVars }}`{{ join $flag.EnvVars "`, `" }}`{{ else }}*none*{{ end }} | ||
| {{- end -}} | ||
| {{- /**/ -}} | | ||
| {{ end }} | ||
| {{ end }} | ||
|
|
||
| {{ define "command" }} | ||
| ### `{{ .Name }}` {{ if gt .Level 0 }}sub{{ end }}command{{ if .Aliases }} (aliases: `{{ join .Aliases "`, `" }}`){{ end }} | ||
| {{ if .Usage }} | ||
| {{ .Usage }}. | ||
| {{ end }} | ||
| {{ if .UsageText }} | ||
| {{ range $line := .UsageText -}} | ||
| > {{ $line }} | ||
| {{ end -}} | ||
| {{ end }} | ||
| {{ if .Description }} | ||
| {{ .Description }}. | ||
| {{ end }} | ||
| Usage: | ||
|
|
||
| ```bash | ||
| $ {{ .AppPath }} [GLOBAL FLAGS] {{ .Name }}{{ if .Flags }} [COMMAND FLAGS]{{ end }} {{ if .ArgsUsage }}{{ .ArgsUsage }}{{ else }}[ARGUMENTS...]{{ end }} | ||
| ``` | ||
|
|
||
| {{ if .Flags -}} | ||
| The following flags are supported: | ||
| {{ template "flags" .Flags }} | ||
| {{ end -}} | ||
|
|
||
| {{ if .SubCommands -}} | ||
| {{ range $subCmd := .SubCommands -}} | ||
| {{ template "command" $subCmd }} | ||
| {{ end -}} | ||
| {{ end -}} | ||
| {{ end }} | ||
|
|
||
| ## CLI interface{{ if .Name }} - {{ .Name }}{{ end }} | ||
|
|
||
| {{ if .Description }}{{ .Description }}. | ||
| {{ end }} | ||
| {{ if .Usage }}{{ .Usage }}. | ||
| {{ end }} | ||
| {{ if .UsageText }} | ||
| {{ range $line := .UsageText -}} | ||
| > {{ $line }} | ||
| {{ end -}} | ||
| {{ end }} | ||
| Usage: | ||
|
|
||
| ```bash | ||
| $ {{ .AppPath }}{{ if .GlobalFlags }} [GLOBAL FLAGS]{{ end }} [COMMAND] [COMMAND FLAGS] {{ if .ArgsUsage }}{{ .ArgsUsage }}{{ else }}[ARGUMENTS...]{{ end }} | ||
| ``` | ||
|
|
||
| {{ if .GlobalFlags }} | ||
| Global flags: | ||
|
|
||
| {{ template "flags" .GlobalFlags }} | ||
|
|
||
| {{ end -}} | ||
| {{ if .Commands -}} | ||
| {{ range $cmd := .Commands -}} | ||
| {{ template "command" $cmd }} | ||
| {{ end }} | ||
| {{- end }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.