Skip to content

Commit

Permalink
feat(agoric): implement agoric run script -- script-args...
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelfig committed Jan 13, 2022
1 parent f599585 commit fd3938e
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 30 deletions.
1 change: 1 addition & 0 deletions packages/agoric-cli/src/deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ export { bootPlugin } from ${JSON.stringify(absPath)};
installUnsafePlugin,
host,
port,
args: opts.scriptArgs,
});
}
}
Expand Down
84 changes: 54 additions & 30 deletions packages/agoric-cli/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,39 +160,63 @@ const main = async (progname, rawArgs, powers) => {
return subMain(installMain, ['install', forceSdkVersion], opts);
});

program
.command('deploy [script...]')
.description(
'run a deployment script with all your user privileges against the local Agoric VM',
)
.option(
'--allow-unsafe-plugins',
`CAREFUL: installed Agoric VM plugins will also have all your user's privileges`,
false,
)
.option(
'--hostport <host:port>',
'host and port to connect to VM',
'127.0.0.1:8000',
)
.option(
'--need <subsystems>',
'comma-separated names of subsystems to wait for',
'local,agoric,wallet',
)
.option(
'--provide <subsystems>',
'comma-separated names of subsystems this script initializes',
'',
)
.action(async (scripts, cmd) => {
const opts = { ...program.opts(), ...cmd.opts() };
return subMain(deployMain, ['deploy', ...scripts], opts);
});
const addRunOptions = cmd =>
cmd
.option(
'--allow-unsafe-plugins',
`CAREFUL: installed Agoric VM plugins will also have all your user's privileges`,
false,
)
.option(
'--hostport <host:port>',
'host and port to connect to VM',
'127.0.0.1:8000',
)
.option(
'--need <subsystems>',
'comma-separated names of subsystems to wait for',
'local,agoric,wallet',
)
.option(
'--provide <subsystems>',
'comma-separated names of subsystems this script initializes',
'',
);

addRunOptions(
program
.command('run <script> [script-args...]')
.description(
'run a script with all your user privileges against the local Agoric VM',
),
).action(async (script, scriptArgs, cmd) => {
const opts = { ...program.opts(), ...cmd.opts(), scriptArgs };
return subMain(deployMain, ['run', script], opts);
});

addRunOptions(
program
.command('deploy [script...]')
.description(
'run multiple scripts with all your user privileges against the local Agoric VM',
),
).action(async (scripts, cmd) => {
const opts = { ...program.opts(), ...cmd.opts() };
return subMain(deployMain, ['deploy', ...scripts], opts);
});

program
.command('start [profile] [args...]')
.description('run an Agoric VM')
.description(
`\
start an Agoric VM
agoric start - runs the default profile (dev)
agoric start dev -- [initArgs] - simulated chain and solo VM
agoric start local-chain [portNum] -- [initArgs] - local chain
agoric start local-solo [portNum] [provisionPowers] - local solo VM
`,
)
.option('-d, --debug', 'run in JS debugger mode')
.option('--reset', 'clear all VM state before starting')
.option('--no-restart', 'do not actually start the VM')
Expand Down

0 comments on commit fd3938e

Please sign in to comment.