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

add alias to job configuration #297

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

tversteeg
Copy link

@tversteeg tversteeg commented Jan 12, 2025

This allows you to write:

[jobs.example]
alias = ["ex", "exs"]
command = []

So you can do bacon example, bacon ex and bacon exs.

@Canop
Copy link
Owner

Canop commented Jan 12, 2025

Is that really needed ?

This raises a question for users: when defining a job so as to replace another one, which is frequent, do you also automatically replace the aliases? Or do you have to specify the same set of aliases ?

@tversteeg
Copy link
Author

tversteeg commented Jan 13, 2025

If it's really needed is of course highly subjective, but for my use cases it would be a nice feature.

This raises a question for users: when defining a job so as to replace another one, which is frequent, do you also automatically replace the aliases? Or do you have to specify the same set of aliases ?

I would say that it should completely replace the existing aliases, that would also be the current implementation.

@Canop
Copy link
Owner

Canop commented Jan 13, 2025

I wasn't clear.

Imagine there's a team specific job "check" with alias "c", and a key-binding c = "job:check". Some team member get used to bacon c.

Now, on a project of this team, a bacon.toml defines a new "check"job because it uses special features maybe. Most members of the team will probably be surprised that bacon check and bacon c no longer do the same thing, and that the c shortcut doesn't call anymore the same job than called with bacon c job.

@tversteeg
Copy link
Author

tversteeg commented Jan 13, 2025

The c shortcut not calling the new "check" job is not related to this PR, right?

If the new "check" job definition doesn't add the "c" alias, bacon check would work as intended and bacon c would throw an error that the job could not be found. I think this behavior makes sense.

Another option would be to merge all aliases from each previous job definition in the new job definition.

Yet another option would be to keep the previous job definitions and still allow their aliases to be called if they are not overwritten in the new definition.

@Canop
Copy link
Owner

Canop commented Jan 16, 2025

Other user opinions welcome

@c-git
Copy link
Contributor

c-git commented Jan 16, 2025

IMHO I actually think adding aliases complicates the mental for me a bit of how bacon works and which job I would expect to actually be run. I don't personally have a need for aliases and it doesn't really affect me either way as I generally work with hotkeys and do not restart bacon to change job so I don't really have a horse in the race. That disclaimer added if I did need aliases I think I would create a job for each alias instead of defining them in the job I want aliased (Example below). I think that would make it more obvious what priority they have based on where they are defined. It is more typing so if it were something I used often I could see how I would want the syntactic sugar instead.

[jobs.example]
command = ["cargo", "run", "--example"]
need_stdout = true
allow_warnings = true

[jobs.ex]
command = ["echo", "alias used"]
on_success = "job:example"

[jobs.exs]
command = ["echo", "alias used"]
on_success = "job:example"

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.

3 participants