Skip to content

Commit b6c0cb6

Browse files
committed
feat: add -c flag for phoenix
1 parent 6e1ed7a commit b6c0cb6

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

src/phoenix/src/main_puter.js

+19
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import { CreateDriversProvider } from './platform/puter/drivers.js';
2323
import { XDocumentPTT } from './pty/XDocumentPTT.js';
2424
import { CreateEnvProvider } from './platform/puter/env.js';
2525
import { CreateSystemProvider } from './platform/puter/system.js';
26+
import { parseArgs } from '@pkgjs/parseargs';
2627

2728
window.main_shell = async () => {
2829
const config = Object.fromEntries(
@@ -71,9 +72,27 @@ window.main_shell = async () => {
7172
// await puterSDK.setAuthToken(config['puter.auth.token']);
7273
// }
7374

75+
// TODO: move this into Puter's SDK instead
76+
if ( ! puter.args?.command_line?.args ) {
77+
puter.args.command_line = {};
78+
puter.args.command_line.args = [];
79+
}
80+
81+
// Argument parsing happens here
82+
// puter.args < -- command_line.args
83+
const { values } = parseArgs({
84+
options: {
85+
c: {
86+
type: 'string'
87+
}
88+
},
89+
args: puter.args.command_line.args
90+
});
91+
7492
await launchPuterShell(new Context({
7593
ptt,
7694
config, puterSDK,
95+
init_arguments: values,
7796
externs: new Context({ puterSDK }),
7897
platform: new Context({
7998
name: 'puter',

src/phoenix/src/puter-shell/main.js

+5
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,11 @@ export const launchPuterShell = async (ctx) => {
193193

194194
ctx.externs.out.write('\n');
195195

196+
if ( ctx.init_arguments.c ) {
197+
await ansiShell.runPipeline(ctx.init_arguments.c);
198+
return;
199+
}
200+
196201
for ( ;; ) {
197202
await ansiShell.doPromptIteration();
198203
}

0 commit comments

Comments
 (0)