Skip to content

Commit

Permalink
allow to specify a git branch to mention in the readme
Browse files Browse the repository at this point in the history
  • Loading branch information
can3p committed Apr 5, 2024
1 parent 656aeaa commit 8c9f871
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
9 changes: 9 additions & 0 deletions cmd/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,17 @@ func GenerateCommand() *cobra.Command {
RunE: func(cmd *cobra.Command, args []string) error {
projectName := cmd.Flag("project-name").Value.String()
githubRepo := cmd.Flag("github-repo").Value.String()
gitBranch := cmd.Flag("git-branch").Value.String()
out := cmd.Flag("out").Value.String()

if githubRepo == "" {
return errors.Errorf("Github repo is missing")
}

if gitBranch == "" {
return errors.Errorf("Git branch is missing")
}

s := scaffolder.New()

if !test {
Expand All @@ -35,6 +40,7 @@ func GenerateCommand() *cobra.Command {
return s.Scaffold(kleinerTemplate.Template, scaffolder.ScaffoldData{
"ProjectName": projectName,
"GithubRepo": githubRepo,
"GitBranch": gitBranch,
})
},
}
Expand All @@ -56,8 +62,11 @@ func GenerateCommand() *cobra.Command {
log.Println(err)
}

var gitBranch string = "main"

generateCmd.Flags().String("project-name", projectName, "Project and binary name, current folder name by default")
generateCmd.Flags().String("github-repo", githubRepo, "Github repo in form user/repo")
generateCmd.Flags().String("git-branch", gitBranch, "Git branch to refer in the readme")
generateCmd.Flags().String("out", path, "Output folder")
generateCmd.Flags().BoolVarP(&test, "test", "", false, "Do not write anything, write everything to stdout")

Expand Down
4 changes: 2 additions & 2 deletions template/README.md.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ Download `{{ .ProjectName }}` and install into a local bin directory.
Latest version:

```bash
curl -L https://raw.githubusercontent.com/{{ .GithubRepo }}/main/generated/install.sh | sh
curl -L https://raw.githubusercontent.com/{{ .GithubRepo }}/{{ .GitBranch }}/generated/install.sh | sh
```

Specific version:

```bash
curl -L https://raw.githubusercontent.com/{{ .GithubRepo }}/main/generated/install.sh | sh -s 0.0.4
curl -L https://raw.githubusercontent.com/{{ .GithubRepo }}/{{ .GitBranch }}/generated/install.sh | sh -s 0.0.4
```

The script will install the binary into `$HOME/bin` folder by default, you can override this by setting
Expand Down

0 comments on commit 8c9f871

Please sign in to comment.