Skip to content

Commit

Permalink
Remove task alias
Browse files Browse the repository at this point in the history
  • Loading branch information
zakuro9715 committed Feb 23, 2021
1 parent bd2e0bd commit 6c165fd
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 9 deletions.
3 changes: 0 additions & 3 deletions cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,6 @@ func findTask(i *int, nzargs []nzflag.Value, config *config.Config) (task *confi
if newTask, err := config.FindTask(fullName); err == nil {
*i = i2 + 1
task = newTask
if len(task.AliasTo) > 0 {
task, _ = config.FindTask(task.AliasTo)
}
}
}
}
Expand Down
5 changes: 1 addition & 4 deletions config/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ type task struct {
Cmds yaml.StringList `yaml:"run"`
Envs Envs `yaml:"env"`
Paths yaml.StringList `yaml:"path"`
AliasTo string `yaml:"z"`
Config *Config
Parent *Task
Description string `yaml:"desc"`
Expand Down Expand Up @@ -119,10 +118,8 @@ func (t *Task) expandVars() {
}

func (t *Task) Verify() error {
if len(t.Cmds) == 0 && len(t.AliasTo) == 0 {
if len(t.Cmds) == 0 {
return errors.New("Nothing to run")
} else if len(t.Cmds) > 0 && len(t.AliasTo) > 0 {
return errors.New("Cannot use both of `z` and `run`")
}
return nil
}
Expand Down
2 changes: 0 additions & 2 deletions config/task_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,5 @@ import (

func TestVerify(t *testing.T) {
assert.NoError(t, (&Task{task{Cmds: []string{"v"}}}).Verify())
assert.NoError(t, (&Task{task{AliasTo: "v"}}).Verify())
assert.Error(t, (&Task{}).Verify())
assert.Error(t, (&Task{task{Cmds: []string{"v"}, AliasTo: "v"}}).Verify())
}

0 comments on commit 6c165fd

Please sign in to comment.