Compare commits

..

No commits in common. "4b7aa8a03e3d2b9a15ba4efce4df57362f468416" and "4981a14e14908c4b15ff4a22a600b61a49508126" have entirely different histories.

2 changed files with 4 additions and 22 deletions

2
FAQ.md
View File

@ -113,7 +113,7 @@ I realize that many users will be using GitHub, and most will likely still be us
## Backup and Restore ## Backup and Restore
1. The simplest solution is to make a copy of your `registry.yaml` (default: `~/.tmpl/registry.yaml`). 1. The simplest solution is to make a copy of your `registry.toml` (default: `~/.tmpl/registry.toml`).
* Once in the new location, you will need to use `tmpl restore`. * Once in the new location, you will need to use `tmpl restore`.
2. Alternatively, you can copy/paste the entire registry (default: `~/.tmpl`) and skip the restore step. 2. Alternatively, you can copy/paste the entire registry (default: `~/.tmpl`) and skip the restore step.

View File

@ -2,8 +2,6 @@ package cmd
import ( import (
"fmt" "fmt"
"os"
"path"
"strings" "strings"
"go.jolheiser.com/tmpl/env" "go.jolheiser.com/tmpl/env"
@ -17,7 +15,7 @@ var Download = &cli.Command{
Name: "download", Name: "download",
Usage: "Download a template", Usage: "Download a template",
Description: "Download a template and save it to the local registry", Description: "Download a template and save it to the local registry",
ArgsUsage: "[repository URL] <name>", ArgsUsage: "[repository URL] [name]",
Flags: []cli.Flag{ Flags: []cli.Flag{
&cli.StringFlag{ &cli.StringFlag{
Name: "branch", Name: "branch",
@ -31,7 +29,7 @@ var Download = &cli.Command{
} }
func runDownload(ctx *cli.Context) error { func runDownload(ctx *cli.Context) error {
if ctx.NArg() < 1 { if ctx.NArg() < 2 {
return cli.ShowCommandHelp(ctx, ctx.Command.Name) return cli.ShowCommandHelp(ctx, ctx.Command.Name)
} }
@ -69,7 +67,7 @@ func runDownload(ctx *cli.Context) error {
cloneURL += ".git" cloneURL += ".git"
} }
t, err := reg.DownloadTemplate(deriveName(ctx), cloneURL, ctx.String("branch")) t, err := reg.DownloadTemplate(ctx.Args().Get(1), cloneURL, ctx.String("branch"))
if err != nil { if err != nil {
return err return err
} }
@ -77,19 +75,3 @@ func runDownload(ctx *cli.Context) error {
log.Info().Msgf("Added new template %q", t.Name) log.Info().Msgf("Added new template %q", t.Name)
return nil return nil
} }
func deriveName(ctx *cli.Context) string {
if ctx.NArg() > 1 {
return ctx.Args().Get(1)
}
envBranch, envSet := os.LookupEnv("TMPL_BRANCH")
flagBranch, flagSet := ctx.String("branch"), ctx.IsSet("branch")
if flagSet {
if !envSet || envBranch != flagBranch {
return flagBranch
}
}
return path.Base(ctx.Args().First())
}