-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
301320c
commit 3f85be6
Showing
4 changed files
with
75 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { runCommand } from "../command"; // Assuming runCommand is a function that executes shell commands | ||
import { consola } from "consola"; | ||
import ora from "ora"; | ||
|
||
interface ServiceOptions { | ||
all?: boolean; | ||
json?: boolean; | ||
debug?: boolean; | ||
quiet?: boolean; | ||
verbose?: boolean; | ||
file?: string; | ||
serviceUser ?: string; | ||
maxWait?: number; | ||
noWait?: boolean; | ||
} | ||
|
||
export async function handleServices(subcommand: string, formula?: string, options?: ServiceOptions) { | ||
const spinner = ora(`🔄 Executing brew services ${subcommand}...`).start(); // Start spinner with emoji | ||
|
||
try { | ||
let command = `brew services ${subcommand}`; | ||
|
||
// Handle options | ||
if (options) { | ||
if (options.all) command += ' --all'; | ||
if (options.json) command += ' --json'; | ||
if (options.debug) command += ' --debug'; | ||
if (options.quiet) command += ' --quiet'; | ||
if (options.verbose) command += ' --verbose'; | ||
if (options.file) command += ` --file=${options.file}`; | ||
if (options.serviceUser ) command += ` --sudo-service-user=${options.serviceUser }`; | ||
if (options.maxWait !== undefined) command += ` --max-wait=${options.maxWait}`; | ||
if (options.noWait) command += ' --no-wait'; | ||
} | ||
|
||
if (formula) { | ||
command += ` ${formula}`; | ||
} | ||
|
||
const result = await runCommand(command); | ||
spinner.succeed(`✅ Successfully executed: ${command}`); // Success message with emoji | ||
|
||
// Output the result | ||
if (!options?.quiet) { | ||
consola.info(`📜 ${result}`); // Output result with an emoji | ||
} | ||
} catch (error: any) { | ||
spinner.fail(`❌ Error executing brew services ${subcommand}: ${error.message}`); // Error message with emoji | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters