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 the -e top-level switch to show examples #7

Merged
merged 1 commit into from
Jul 22, 2024
Merged

Conversation

jftuga
Copy link
Owner

@jftuga jftuga commented Jul 21, 2024

  • The -e option to show examples pulls in the README.md into the compiled binary using go:embed.
    • By using this approach, a separate copy of the CLI examples do not have to be maintained.
  • Improved Usage by separating sections with ---
  • Improved Examples by separating commands with #### "dtmate command" examples ####

var optRootShowExamples bool
var readmeExamplesRegex = regexp.MustCompile(`(?ms)## Command Line Examples.*?shell\n(.*?)` + "```")

//go:embed README.md

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't you use a relative path here?

Suggested change
//go:embed README.md
//go:embed ../../../README.md

This way you don't need a go generate

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately no. go:embed does not allow for this.

cmd/dtmate/cmd/root.go Show resolved Hide resolved
README.md Show resolved Hide resolved
@jftuga jftuga merged commit fbdee45 into main Jul 22, 2024
@jftuga jftuga deleted the examples branch July 24, 2024 00:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants