Skip to content

Commit

Permalink
refactor: update run:inside help text and add named args (#3108)
Browse files Browse the repository at this point in the history
* chore: update run:inside help text

* refactor: add named args to run:inside
  • Loading branch information
k80bowman authored Nov 22, 2024
1 parent 46de2d7 commit 5c3fd07
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 14 deletions.
1 change: 1 addition & 0 deletions cspell-dictionary.txt
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ psubscribe
psut
psql
psqlrc
pvpr
pxxxxxxxx
qqjs
raulb
Expand Down
33 changes: 19 additions & 14 deletions packages/cli/src/commands/run/inside.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
import {Command, flags} from '@heroku-cli/command'
import {ux} from '@oclif/core'
import {Args, ux} from '@oclif/core'
import debugFactory from 'debug'
import Dyno from '../../lib/run/dyno'
import {buildCommand} from '../../lib/run/helpers'
import heredoc from 'tsheredoc'

const debug = debugFactory('heroku:run:inside')

export default class RunInside extends Command {
static description = 'run a one-off process inside an existing heroku dyno'
static description = 'run a one-off process inside an existing heroku dyno (for Fir-generation apps only)'

static hidden = true;

static examples = [
'$ heroku run:inside web.1 bash',
]
static example = heredoc`
Run bash
$ heroku run:inside web-848cd4f64d-pvpr2 bash
Run a command supplied by a script
$ heroku run:inside web-848cd4f64d-pvpr2 -- myscript.sh
Run a command declared for the worker process type in a Procfile
$ heroku run:inside worker
`

static flags = {
app: flags.app({required: true}),
Expand All @@ -22,20 +26,21 @@ export default class RunInside extends Command {
listen: flags.boolean({description: 'listen on a local port', hidden: true}),
}

static args = {
DYNO_NAME: Args.string({required: true, description: 'name of the dyno to run command inside'}),
COMMAND: Args.string({required: true, description: 'command to run'}),
}

static strict = false

async run() {
const {flags, argv} = await this.parse(RunInside)

if (argv.length < 2) {
throw new Error('Usage: heroku run:inside DYNO COMMAND\n\nExample: heroku run:inside web.1 bash')
}
const {flags, args} = await this.parse(RunInside)

const opts = {
'exit-code': flags['exit-code'],
app: flags.app,
command: buildCommand(argv.slice(1) as string[]),
dyno: argv[0] as string,
command: buildCommand([args.COMMAND]),
dyno: args.DYNO_NAME,
heroku: this.heroku,
listen: flags.listen,
}
Expand Down

0 comments on commit 5c3fd07

Please sign in to comment.