chore(go): inject stdin and pass rc force explicitly
This commit is contained in:
@@ -21,13 +21,15 @@ type App struct {
|
||||
Stdin io.Reader
|
||||
Stdout io.Writer
|
||||
Stderr io.Writer
|
||||
Verbose bool
|
||||
Force bool
|
||||
Quiet bool
|
||||
Pretend bool
|
||||
}
|
||||
|
||||
func New(stdout io.Writer, stderr io.Writer) (*App, error) {
|
||||
func NewApp(stdin io.Reader, stdout io.Writer, stderr io.Writer) (*App, error) {
|
||||
if stdin == nil {
|
||||
return nil, errors.New("stdin reader cannot be nil")
|
||||
}
|
||||
if stdout == nil {
|
||||
return nil, errors.New("stdout writer cannot be nil")
|
||||
}
|
||||
@@ -43,7 +45,7 @@ func New(stdout io.Writer, stderr io.Writer) (*App, error) {
|
||||
return &App{
|
||||
HomeDir: home,
|
||||
ReposDir: filepath.Join(home, ".homesick", "repos"),
|
||||
Stdin: os.Stdin,
|
||||
Stdin: stdin,
|
||||
Stdout: stdout,
|
||||
Stderr: stderr,
|
||||
}, nil
|
||||
@@ -845,7 +847,7 @@ func gitOutput(dir string, args ...string) (string, error) {
|
||||
// If a .homesickrc file exists in the castle root and no parity.rb wrapper
|
||||
// already exists in .homesick.d, a Ruby wrapper script named parity.rb is
|
||||
// written there before execution so that it sorts first.
|
||||
func (a *App) Rc(castle string) error {
|
||||
func (a *App) Rc(castle string, force bool) error {
|
||||
castleRoot := filepath.Join(a.ReposDir, castle)
|
||||
if _, err := os.Stat(castleRoot); err != nil {
|
||||
if errors.Is(err, os.ErrNotExist) {
|
||||
@@ -857,7 +859,7 @@ func (a *App) Rc(castle string) error {
|
||||
homesickD := filepath.Join(castleRoot, ".homesick.d")
|
||||
homesickRc := filepath.Join(castleRoot, ".homesickrc")
|
||||
|
||||
if _, err := os.Stat(homesickRc); err == nil && !a.Force {
|
||||
if _, err := os.Stat(homesickRc); err == nil && !force {
|
||||
return errors.New("refusing to run legacy .homesickrc without --force")
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user