File tree 2 files changed +24
-0
lines changed
2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ import { CreateDriversProvider } from './platform/puter/drivers.js';
23
23
import { XDocumentPTT } from './pty/XDocumentPTT.js' ;
24
24
import { CreateEnvProvider } from './platform/puter/env.js' ;
25
25
import { CreateSystemProvider } from './platform/puter/system.js' ;
26
+ import { parseArgs } from '@pkgjs/parseargs' ;
26
27
27
28
window . main_shell = async ( ) => {
28
29
const config = Object . fromEntries (
@@ -71,9 +72,27 @@ window.main_shell = async () => {
71
72
// await puterSDK.setAuthToken(config['puter.auth.token']);
72
73
// }
73
74
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
+
74
92
await launchPuterShell ( new Context ( {
75
93
ptt,
76
94
config, puterSDK,
95
+ init_arguments : values ,
77
96
externs : new Context ( { puterSDK } ) ,
78
97
platform : new Context ( {
79
98
name : 'puter' ,
Original file line number Diff line number Diff line change @@ -193,6 +193,11 @@ export const launchPuterShell = async (ctx) => {
193
193
194
194
ctx . externs . out . write ( '\n' ) ;
195
195
196
+ if ( ctx . init_arguments . c ) {
197
+ await ansiShell . runPipeline ( ctx . init_arguments . c ) ;
198
+ return ;
199
+ }
200
+
196
201
for ( ; ; ) {
197
202
await ansiShell . doPromptIteration ( ) ;
198
203
}
You can’t perform that action at this time.
0 commit comments