gitarsenal-cli 1.3.1 → 1.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bin/gitarsenal.js CHANGED
@@ -34,10 +34,12 @@ const containerCmd = program
34
34
  .description('Create a container with a GitHub repository')
35
35
  .option('-g, --gpu <type>', 'GPU type (A10G, A100, H100, T4, L4, L40S, V100)', 'A10G')
36
36
  .option('-r, --repo-url <url>', 'GitHub repository URL')
37
- .option('-v, --volume-name <name>', 'Name of persistent volume')
37
+ .option('-v, --volume-name <n>', 'Name of persistent volume')
38
38
  .option('-s, --setup-commands <commands...>', 'Setup commands to run in the container')
39
39
  .option('-y, --yes', 'Skip confirmation prompts')
40
40
  .option('-m, --manual', 'Disable automatic setup command detection')
41
+ .option('-i, --interactive', 'Run in interactive mode with prompts')
42
+ .option('--show-examples', 'Show usage examples')
41
43
  .action(async (options) => {
42
44
  await runContainerCommand(options);
43
45
  });
@@ -86,9 +88,11 @@ program
86
88
  .option('-v, --volume <n>', 'Name of persistent volume')
87
89
  .option('-y, --yes', 'Skip confirmation prompts')
88
90
  .option('-m, --manual', 'Disable automatic setup command detection')
91
+ .option('-i, --interactive', 'Run in interactive mode with prompts')
92
+ .option('--show-examples', 'Show usage examples')
89
93
  .action(async (options) => {
90
94
  // If options are provided directly, run the container command
91
- if (options.repo || process.argv.length <= 3) {
95
+ if (options.repo || options.interactive || options.showExamples || process.argv.length <= 3) {
92
96
  await runContainerCommand(options);
93
97
  }
94
98
  });
@@ -97,6 +101,14 @@ program.parse(process.argv);
97
101
 
98
102
  async function runContainerCommand(options) {
99
103
  try {
104
+ // If show-examples flag is set, just show examples and exit
105
+ if (options.showExamples) {
106
+ await runContainer({
107
+ showExamples: true
108
+ });
109
+ return;
110
+ }
111
+
100
112
  // Check for required dependencies
101
113
  const spinner = ora('Checking dependencies...').start();
102
114
  const dependenciesOk = await checkDependencies();
@@ -107,6 +119,14 @@ async function runContainerCommand(options) {
107
119
  }
108
120
  spinner.succeed('Dependencies checked');
109
121
 
122
+ // If interactive mode is enabled, let the Python script handle the prompts
123
+ if (options.interactive) {
124
+ await runContainer({
125
+ interactive: true
126
+ });
127
+ return;
128
+ }
129
+
110
130
  // If repo URL not provided, prompt for it
111
131
  let repoUrl = options.repoUrl || options.repo;
112
132
  let gpuType = options.gpu;
package/lib/sandbox.js CHANGED
@@ -33,10 +33,20 @@ function getPythonScriptPath() {
33
33
  * @param {string} options.volumeName - Volume name
34
34
  * @param {Array<string>} options.setupCommands - Setup commands
35
35
  * @param {boolean} options.useApi - Whether to use the API to fetch setup commands
36
+ * @param {boolean} options.interactive - Whether to run in interactive mode
37
+ * @param {boolean} options.showExamples - Whether to show usage examples
36
38
  * @returns {Promise<void>}
37
39
  */
38
40
  async function runContainer(options) {
39
- const { repoUrl, gpuType, volumeName, setupCommands = [], useApi = true } = options;
41
+ const {
42
+ repoUrl,
43
+ gpuType,
44
+ volumeName,
45
+ setupCommands = [],
46
+ useApi = true,
47
+ interactive = false,
48
+ showExamples = false
49
+ } = options;
40
50
 
41
51
  // Get the path to the Python script
42
52
  const scriptPath = getPythonScriptPath();
@@ -48,10 +58,44 @@ async function runContainer(options) {
48
58
 
49
59
  // Prepare command arguments
50
60
  const args = [
51
- scriptPath,
52
- '--gpu', gpuType,
53
- '--repo-url', repoUrl
61
+ scriptPath
54
62
  ];
63
+
64
+ // If show examples is true, only pass that flag
65
+ if (showExamples) {
66
+ args.push('--show-examples');
67
+
68
+ // Log the command being executed
69
+ console.log(chalk.dim(`\nExecuting: python ${args.join(' ')}`));
70
+
71
+ // Run the Python script with show examples flag
72
+ const pythonProcess = spawn('python', args, {
73
+ stdio: 'inherit' // Inherit stdio to show real-time output
74
+ });
75
+
76
+ return new Promise((resolve, reject) => {
77
+ pythonProcess.on('close', (code) => {
78
+ if (code === 0) {
79
+ resolve();
80
+ } else {
81
+ reject(new Error(`Process exited with code ${code}`));
82
+ }
83
+ });
84
+
85
+ pythonProcess.on('error', (error) => {
86
+ reject(error);
87
+ });
88
+ });
89
+ }
90
+
91
+ // Add interactive flag if specified
92
+ if (interactive) {
93
+ args.push('--interactive');
94
+ } else {
95
+ // Only add these arguments in non-interactive mode
96
+ if (gpuType) args.push('--gpu', gpuType);
97
+ if (repoUrl) args.push('--repo-url', repoUrl);
98
+ }
55
99
 
56
100
  if (volumeName) {
57
101
  args.push('--volume-name', volumeName);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gitarsenal-cli",
3
- "version": "1.3.1",
3
+ "version": "1.3.2",
4
4
  "description": "CLI tool for creating Modal sandboxes with GitHub repositories",
5
5
  "main": "index.js",
6
6
  "bin": {