Skip to content

Conversation

@ischaaf
Copy link

@ischaaf ischaaf commented Jan 13, 2019

Overview

Added a new function bake_task_alias to be used alongside or in place of bake_task. bake_task_alias works similarly to bake_task except that it accepts an additional argument indicating the name of the bash function to call for this task.

bake_task name [description]
# vs
bake_task_alias name function_name [description]

The key functionality here allows for creating tasks in which the task name and function name differ.

# from sandbox/Bakefile
function run.my.program () {
  echo "lets run the program! $*"
}

# Alias the "run.my.program" function to "run"
bake_task_alias run run.my.program "Run the program [alias]"

This will generate the following task list

> ../bake

../bake task [arg ...]

  run                            Run the program [alias]

> ../bake run
lets run the program!

…e_task_alias function for creating tasks where the task_name and function_name are different
bake Outdated
name="${1:-}"
fn_name="${2:-}"
local short_desc="${3:-No Description for task: $name}"
if [ -z "$name" ] || [ -z "$fn_name" ]; then
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it's OK w/you, lets try to use [[ in lieu of [ (apologies if I'm not doing that consistently elsewhere), this could then be written as:

  if [[ -z "$name" && -z "$fn_name" ]]; then

bake Outdated
fn_name="${2:-}"
local short_desc="${3:-No Description for task: $name}"
if [ -z "$name" ] || [ -z "$fn_name" ]; then
echo "Error[bake_task_alias]: you must supply a task name and function name!"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could it make sense to use bake_echo_red here?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It could, actually, now that I'm thinking about it, we could use bake_log_fatal or bake_log_error

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

Successfully merging this pull request may close these issues.

2 participants