feat(cli): make the dotfiles repository directory configurable (#10377)

This commit is contained in:
Josh Vawdrey
2023-10-24 20:00:04 +11:00
committed by GitHub
parent d8592bf09a
commit 6b2aee4133
4 changed files with 88 additions and 5 deletions

View File

@ -22,6 +22,7 @@ import (
func (r *RootCmd) dotfiles() *clibase.Cmd {
var symlinkDir string
var gitbranch string
var dotfilesRepoDir string
cmd := &clibase.Cmd{
Use: "dotfiles <git_repo_url>",
@ -35,11 +36,10 @@ func (r *RootCmd) dotfiles() *clibase.Cmd {
),
Handler: func(inv *clibase.Invocation) error {
var (
dotfilesRepoDir = "dotfiles"
gitRepo = inv.Args[0]
cfg = r.createConfig()
cfgDir = string(cfg)
dotfilesDir = filepath.Join(cfgDir, dotfilesRepoDir)
gitRepo = inv.Args[0]
cfg = r.createConfig()
cfgDir = string(cfg)
dotfilesDir = filepath.Join(cfgDir, dotfilesRepoDir)
// This follows the same pattern outlined by others in the market:
// https://github.com/coder/coder/pull/1696#issue-1245742312
installScriptSet = []string{
@ -290,6 +290,13 @@ func (r *RootCmd) dotfiles() *clibase.Cmd {
"If empty, will default to cloning the default branch or using the existing branch in the cloned repo on disk.",
Value: clibase.StringOf(&gitbranch),
},
{
Flag: "repo-dir",
Default: "dotfiles",
Env: "CODER_DOTFILES_REPO_DIR",
Description: "Specifies the directory for the dotfiles repository, relative to global config directory.",
Value: clibase.StringOf(&dotfilesRepoDir),
},
cliui.SkipPromptOption(),
}
return cmd