Skip to content

feat: add the -e top-level switch to show examples#7

Merged
jftuga merged 1 commit intomainfrom
examples
Jul 22, 2024
Merged

feat: add the -e top-level switch to show examples#7
jftuga merged 1 commit intomainfrom
examples

Conversation

@jftuga
Copy link
Copy Markdown
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
Copy link
Copy Markdown

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
Copy Markdown
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.

@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