Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion deno.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ghostmind/run",
"version": "0.3.47",
"version": "0.3.48",
"license": "MIT",
"description": "A comprehensive DevOps automation toolkit for managing Docker containers, GitHub Actions, Terraform infrastructure, HashiCorp Vault, and more",
"exports": {
Expand Down
60 changes: 35 additions & 25 deletions run/lib/misc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -362,16 +362,35 @@ export default async function misc(program: any) {
});

////////////////////////////////////////////////////////////////////////////////
// RUN MCP WITH ENVIRONMENT VARIABLES INJECTED
// PRINT ENVIRONMENT VARIABLE
////////////////////////////////////////////////////////////////////////////////

misc
.command('env')
.description('print the value of an environment variable')
.argument('<variable>', 'environment variable name')
.action((variable: string) => {
const value = Deno.env.get(variable);
if (value !== undefined) {
console.log(value);
} else {
console.log(`Environment variable '${variable}' is not set`);
}
});

////////////////////////////////////////////////////////////////////////////////
// RUN NATIVE COMMAND WITH ENVIRONMENT VARIABLES INJECTED
////////////////////////////////////////////////////////////////////////////////

misc
.command('mcp')
.description('run any command with environment variables injected')
.argument('<command>', 'command to run (e.g., npx, deno, node)')
.argument('[args...]', 'arguments to pass to the command')
.command('cmd')
.description('run any native command with environment variables injected')
.argument(
'<command>',
'full command to run (wrap in quotes if it contains spaces or special characters)'
)
.option('--env <path>', 'path to environment file', '.env')
.action(async (command: string, args: string[], options: any) => {
.action(async (commandString: string, options: any) => {
try {
const envPathInput = options.env || '.env';
const SRC = Deno.env.get('SRC') || '';
Expand All @@ -397,7 +416,15 @@ export default async function misc(program: any) {
);
}

console.error(`Running: ${command} ${args.join(' ')}`);
console.error(`Running: ${commandString}`);

// Parse the command string into command and arguments
// This is a simple split - for more complex parsing, we might need a proper shell parser
const parts = commandString
.split(' ')
.filter((part) => part.length > 0);
const command = parts[0];
const args = parts.slice(1);

// Spawn the process with the specified command and arguments
const process = new Deno.Command(command, {
Expand Down Expand Up @@ -425,27 +452,10 @@ export default async function misc(program: any) {
// Exit with the same code as the child process
Deno.exit(status.code);
} catch (error) {
console.error(`Error running command '${command}':`, error);
console.error(`Error running command '${commandString}':`, error);
Deno.exit(1);
}
});

////////////////////////////////////////////////////////////////////////////////
// PRINT ENVIRONMENT VARIABLE
////////////////////////////////////////////////////////////////////////////////

misc
.command('env')
.description('print the value of an environment variable')
.argument('<variable>', 'environment variable name')
.action((variable: string) => {
const value = Deno.env.get(variable);
if (value !== undefined) {
console.log(value);
} else {
console.log(`Environment variable '${variable}' is not set`);
}
});
}

////////////////////////////////////////////////////////////////////////////////
Expand Down