kamal icon indicating copy to clipboard operation
kamal copied to clipboard

Feature pitch: Support defining of custom CLI commands through deploy.yml

Open dhnaranjo opened this issue 1 year ago • 2 comments

Hey, hi! I think it'd be handy to be able to define aliases in my config file to clean up repetitive commands I might want used across my team. For example allowing me to run kamal app console to get to my Rails console with the following config.

alias:
  app:
    console: app exec -i "bin/rails c --sandbox"
    angry_console: app exec -i "bin/rails c"

We might not want to pollute the cli with custom commands using names that might conflict with future features, so maybe it's all under kamal alias or kamal run or whatever.

If y'all are interested I'd be happy to knock together a PR for it.

dhnaranjo avatar Jan 10 '24 18:01 dhnaranjo

As a workaround, consider incorporating a Makefile into your project. This file can house the custom commands that you and your team frequently utilize.

example

logs.web:
	kamal app logs -f -r web -d production

logs.job:
	kamal app logs -f -r job -d production
	
prod.recalculate:
	kamal app exec -d production -i --reuse 'bundle exec rake ranks:recalculate'

prod.console:
	kamal app exec -d production -i --reuse './bin/rails c'

acidtib avatar Jan 11 '24 21:01 acidtib

In Rails project, we're just defining custom command in bin/some-name-of-the-command. Maybe that would be enough for your needs @dhnaranjo

morgoth avatar Jun 06 '24 05:06 morgoth

See https://github.com/basecamp/kamal/pull/912. Thanks for the great idea @dhnaranjo!

djmb avatar Aug 26 '24 09:08 djmb

Thanks for doing the actual thing, @djmb.

dhnaranjo avatar Sep 04 '24 17:09 dhnaranjo