3

Q: I'm using make as a simple task runner. `make build` instead of a longer build command etc. It sucks that I can't simply pass some params like `make build dev`, instead I have to pass them as variables: `make build tag=dev`.

Can you recommend a standard, cross-platform (Linux, OS X) tool for this?

Comments
  • 0
    @irene That's `tag=dev make build`, still the same amount of typing but less readable.

    Also, necessity to quote multi-words sucks. Ideally I'd like to be able to `make composer require somestuff` instead of `make composer cmd='require somestuff'`.
  • 1
    Add a dev section to makefile and call 'make dev'?
  • 0
    @irene Make treats subsequent arguments as recipe names and runs all of them (which make sense for its original use case), so forking is not an option. Someone in our company already built a custom tool just for this job, but having to use a non-standard tool for such a trivial thing is a shame.

    @electrineer See the composer example. Some commands don't have repeatable arguments and I run them just once.
  • 2
    What about Bash?

    Let's say you have a directory called ~/Tasks. You add a build.sh script there, and then you write your entry point script that just does something like this:

    #!/usr/bin/env bash

    [[ -z "$*" ]] && exit 1

    task_dir="$HOME/Tasks"

    task="$1"

    shift

    task_path="$task_dir/$task.sh"

    if [[ -f "$task_path" ]]; then

    source "$task_path" "$@"

    else

    echo "Task $task doesn't exist." >&2

    exit 1

    fi
  • 0
    @ethernetzero Quite elegant, but command completion won't work. I'm looking for something completely standard. I'm aware of npm scripts, but this is mostly for PHP and using node for executing oneliners is an overkill anyway.
  • 0
    @gronostaj Command completion can work if you add a completion function to your ~/.bashrc that simply lists the files in your ~/Tasks directory.

    Here's a nice tutorial: http://fahdshariff.blogspot.com/201...

    I see that you're looking for some ready-made package, but if nothing turns out you know you can roll your own.
  • 0
    Use cmake with ccmake! That way you can configure everything in a terminal interface
  • 0
    @ethernetzero Yeah, custom completions are pretty cool, but that's not what I want. It must be readily available on Linux/OS X and require no extra configuration.
  • 0
    @gronostaj It's OK. 🙂 Let it serve as a DIY way for anyone that might find it useful, then.
Add Comment