Skip to content

Task identifier shorthand notation / aliases #268

Closed

Description

@aegershman

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 👍

Activity

  1. andreynering commented on Nov 16, 2019

    @andreynering
    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.

  2. tommyalatalo commented on Dec 8, 2019

    @tommyalatalo

    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.

  3. andreynering commented on Dec 16, 2019

    @andreynering
    Member

    @tommyalatalo That makes sense 👍

  4. andreynering commented on Dec 16, 2019

    @andreynering
    Member

    Closed by mistake, sorry.

  5. slashsbin commented on Feb 17, 2020

    @slashsbin

    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.

  6. aegershman commented on Oct 14, 2021

    @aegershman
    Author

    Thanks all 👍 closing for tidyness

  7. tommyalatalo commented on Oct 15, 2021

    @tommyalatalo

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

  8. ghostsquad commented on Feb 20, 2022

    @ghostsquad
    Contributor

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Fields

    No fields configured for feature.

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions