Skip to content

Commit

Permalink
Add handleEdit function for editing Homebrew formulas
Browse files Browse the repository at this point in the history
This commit introduces the handleEdit function, which allows users to edit Homebrew formulas and casks directly from the command line. The function supports options for editing formulas, casks, and printing paths.

- Implemented command building logic
- Added error handling for command execution
- Included emoji support for user-friendly output
  • Loading branch information
transgirllucy committed Dec 4, 2024
1 parent 4f8006b commit 69803ea
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 14 deletions.
5 changes: 3 additions & 2 deletions src/features/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@ export async function handleConfig(options: { quiet?: boolean; verbose?: boolean
if (options.verbose) {
command += ' --verbose';
}

const result = await runCommand(command);
if (!options.quiet) {
consola.info(`🔧 Homebrew Configuration:\n${result}`);
}
} catch (error) {
} catch (error: any) {
if (!options.quiet) {
consola.error(`Error retrieving Homebrew configuration: ${error}`);
consola.error(`Error retrieving Homebrew configuration: ${error.message}`);
}
}
}
8 changes: 4 additions & 4 deletions src/features/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,17 @@ export const handleCreate = async (url: string, options: {
// Handle output based on the options
if (!options.quiet) {
if (stdout) {
consola.log(stdout);
consola.log(`📦 ${stdout}`);
}
if (stderr) {
consola.error(stderr);
consola.error(`⚠️ ${stderr}`);
}
}
} catch (error: any) {
// Handle errors
consola.error(`Error executing brew create: ${error.message}`);
consola.error(`Error executing brew create: ${error.message}`);
if (error.stderr) {
consola.error(error.stderr);
consola.error(`⚠️ ${error.stderr}`);
}
process.exit(1); // Exit with a non-zero status
}
Expand Down
8 changes: 4 additions & 4 deletions src/features/doctor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,17 @@ export const handleDoctor = async (options: {
// Handle output based on the options
if (!options.quiet) {
if (stdout) {
consola.log(stdout);
consola.log(`🩺 ${stdout}`); // Using a stethoscope emoji to indicate health check
}
if (stderr) {
consola.error(stderr);
consola.error(`⚠️ ${stderr}`); // Warning emoji for errors
}
}
} catch (error: any) {
// Handle errors
consola.error(`Error executing brew doctor: ${error.message}`);
consola.error(`Error executing brew doctor: ${error.message}`);
if (error.stderr) {
consola.error(error.stderr);
consola.error(`⚠️ ${error.stderr}`);
}
process.exit(1); // Exit with a non-zero status
}
Expand Down
8 changes: 4 additions & 4 deletions src/features/edit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,17 @@ export const handleEdit = async (args: string[], options: {
// Handle output based on the options
if (!options.quiet) {
if (stdout) {
consola.log(stdout);
consola.log(`✏️ ${stdout}`); // Using a pencil emoji to indicate editing
}
if (stderr) {
consola.error(stderr);
consola.error(`⚠️ ${stderr}`); // Warning emoji for errors
}
}
} catch (error: any) {
// Handle errors
consola.error(`Error executing brew edit: ${error.message}`);
consola.error(`Error executing brew edit: ${error.message}`);
if (error.stderr) {
consola.error(error.stderr);
consola.error(`⚠️ ${error.stderr}`);
}
process.exit(1); // Exit with a non-zero status
}
Expand Down
7 changes: 7 additions & 0 deletions src/features/version.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import consola from 'consola'; // Ensure this import is correct
import { runCommand } from '../command';


export function handleVersion() {
consola.box("Brewy Version 1.0.0")
}

0 comments on commit 69803ea

Please sign in to comment.