Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Task identifier shorthand notation / aliases #268

Closed
aegershman opened this issue Nov 15, 2019 · 8 comments
Closed

Task identifier shorthand notation / aliases #268

aegershman opened this issue Nov 15, 2019 · 8 comments

Comments

@aegershman
Copy link

In order to allow shorthand notation for tasks, consider allowing a task to be referenced by multiple values. For example, and equivalent in shell would be...

#!/usr/bin/env bash

case "$1" in
dt | do | do-thing | do-the-thing )
  ...
;;

perhaps in a Taskfile.yml it could be...

tasks:
  do-thing:
    cmds:
      - ...
    aliases:
      - dt
      - do
      - do-the-thing

Just an idea, just putting it out there. Feel free to close whenever, etc. Thanks for your time 👍

@andreynering
Copy link
Member

Hi @aegershman,

That's kinda already possible, just more verbose:

version: 2

tasks:
  do-thing:
    cmds:
      - ...

 dt:
    cmds:
      - task: do-thing

 do:
    cmds:
      - task: do-thing

 do-the-thing:
    cmds:
      - task: do-thing

I liked your idea though, and it's probably easy to implement.

@tommyalatalo
Copy link

tommyalatalo commented Dec 8, 2019

Hi @aegershman,

That's kinda already possible, just more verbose:

version: 2

tasks:
  do-thing:
    cmds:
      - ...

 dt:
    cmds:
      - task: do-thing

 do:
    cmds:
      - task: do-thing

 do-the-thing:
    cmds:
      - task: do-thing

I liked your idea though, and it's probably easy to implement.

While you're right about this being kind of possible with your examples, it creates a very cluttered output when doing "task --list". It would be really great to have an "alias:" property to set for tasks, and probably a good way of showing the aliases in the "--list" output would be to just chain them, or have a column for aliases separately.

"chained"

clean c cl:          clean temporary files and folders
build b: 	     build binary
test t: 	     run tests

alias column:

name      alias     description
clean     c cl      clean temporary files and folders
build     b 	    build binary
test      t 	    run tests

Something like the above.

@andreynering
Copy link
Member

@tommyalatalo That makes sense 👍

@andreynering
Copy link
Member

Closed by mistake, sorry.

@slashsbin
Copy link

Here is another idea to achieve shortcuts automatically:
If task names are namespaced with :(the way style guide recommends), then we could support specifying task names using the shortest unambiguous text for each part.

For example lets say we have a task named my:foo:bar, then we could run that task using the name m:f:b.

This is something already supported by many other terminal commands like Symfony Console.

Also If you enter a short command that's ambiguous (i.e. there is more than one command that match), then no command will be run and some suggestions of the possible commands to choose from will be output.

@aegershman
Copy link
Author

Thanks all 👍 closing for tidyness

@tommyalatalo
Copy link

What does that mean - "closing for tidyness"? Is this continued in another issue, if so, which one?

@ghostsquad
Copy link
Contributor

ghostsquad commented Feb 20, 2022

What does that mean - "closing for tidyness"? Is this continued in another issue, if so, which one?

I came here to ask the same thing, then decided to open a new issue (#675), with some concrete examples of how this may be implemented, and some pitfalls.

@pd93 pd93 mentioned this issue Oct 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants