Skip to content
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@mux/cli",
"version": "1.0.0",
"version": "0.0.0",
"description": "Official Mux CLI for interacting with Mux APIs",
"author": "Mux",
"license": "Apache-2.0",
Expand Down
11 changes: 2 additions & 9 deletions src/commands/annotations/create.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Command } from '@cliffy/command';
import { handleCommandError } from '@/lib/errors.ts';
import { createAuthenticatedMuxClient } from '@/lib/mux.ts';

interface CreateOptions {
Expand Down Expand Up @@ -44,14 +45,6 @@ export const createCommand = new Command()
console.log(` Note: ${annotation.note}`);
}
} catch (error) {
const errorMessage =
error instanceof Error ? error.message : String(error);

if (options.json) {
console.error(JSON.stringify({ error: errorMessage }, null, 2));
} else {
console.error(`Error: ${errorMessage}`);
}
process.exit(1);
await handleCommandError(error, 'annotations', 'create', options);
}
});
11 changes: 2 additions & 9 deletions src/commands/annotations/delete.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Command } from '@cliffy/command';
import { handleCommandError } from '@/lib/errors.ts';
import { createAuthenticatedMuxClient } from '@/lib/mux.ts';
import { confirmPrompt } from '@/lib/prompt.ts';

Expand Down Expand Up @@ -46,14 +47,6 @@ export const deleteCommand = new Command()
console.log(`Annotation ${annotationId} deleted successfully.`);
}
} catch (error) {
const errorMessage =
error instanceof Error ? error.message : String(error);

if (options.json) {
console.error(JSON.stringify({ error: errorMessage }, null, 2));
} else {
console.error(`Error: ${errorMessage}`);
}
process.exit(1);
await handleCommandError(error, 'annotations', 'delete', options);
}
});
11 changes: 2 additions & 9 deletions src/commands/annotations/get.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Command } from '@cliffy/command';
import { handleCommandError } from '@/lib/errors.ts';
import { createAuthenticatedMuxClient } from '@/lib/mux.ts';

interface GetOptions {
Expand Down Expand Up @@ -26,14 +27,6 @@ export const getCommand = new Command()
}
}
} catch (error) {
const errorMessage =
error instanceof Error ? error.message : String(error);

if (options.json) {
console.error(JSON.stringify({ error: errorMessage }, null, 2));
} else {
console.error(`Error: ${errorMessage}`);
}
process.exit(1);
await handleCommandError(error, 'annotations', 'get', options);
}
});
11 changes: 2 additions & 9 deletions src/commands/annotations/list.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Command } from '@cliffy/command';
import { handleCommandError } from '@/lib/errors.ts';
import { createAuthenticatedMuxClient } from '@/lib/mux.ts';

interface ListOptions {
Expand Down Expand Up @@ -82,14 +83,6 @@ export const listCommand = new Command()
}
}
} catch (error) {
const errorMessage =
error instanceof Error ? error.message : String(error);

if (options.json) {
console.error(JSON.stringify({ error: errorMessage }, null, 2));
} else {
console.error(`Error: ${errorMessage}`);
}
process.exit(1);
await handleCommandError(error, 'annotations', 'list', options);
}
});
11 changes: 2 additions & 9 deletions src/commands/annotations/update.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Command } from '@cliffy/command';
import { handleCommandError } from '@/lib/errors.ts';
import { createAuthenticatedMuxClient } from '@/lib/mux.ts';

interface UpdateOptions {
Expand Down Expand Up @@ -49,14 +50,6 @@ export const updateCommand = new Command()
console.log(` Note: ${annotation.note}`);
}
} catch (error) {
const errorMessage =
error instanceof Error ? error.message : String(error);

if (options.json) {
console.error(JSON.stringify({ error: errorMessage }, null, 2));
} else {
console.error(`Error: ${errorMessage}`);
}
process.exit(1);
await handleCommandError(error, 'annotations', 'update', options);
}
});
11 changes: 2 additions & 9 deletions src/commands/assets/create.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Command } from '@cliffy/command';
import type Mux from '@mux/mux-node';
import { handleCommandError } from '@/lib/errors.ts';
import { expandGlobPattern, uploadFile } from '@/lib/file-upload.ts';
import { parseAssetConfig } from '@/lib/json-config.ts';
import { createAuthenticatedMuxClient } from '@/lib/mux.ts';
Expand Down Expand Up @@ -471,14 +472,6 @@ export const createCommand = new Command()
}
}
} catch (error) {
const errorMessage =
error instanceof Error ? error.message : String(error);

if (opts.json) {
console.error(JSON.stringify({ error: errorMessage }, null, 2));
} else {
console.error(`Error: ${errorMessage}`);
}
process.exit(1);
await handleCommandError(error, 'assets', 'create', opts);
}
});
11 changes: 2 additions & 9 deletions src/commands/assets/delete.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Command } from '@cliffy/command';
import { handleCommandError } from '@/lib/errors.ts';
import { createAuthenticatedMuxClient } from '@/lib/mux.ts';
import { confirmPrompt } from '@/lib/prompt.ts';

Expand Down Expand Up @@ -46,14 +47,6 @@ export const deleteCommand = new Command()
console.log(`Asset ${assetId} deleted successfully`);
}
} catch (error) {
const errorMessage =
error instanceof Error ? error.message : String(error);

if (options.json) {
console.error(JSON.stringify({ error: errorMessage }, null, 2));
} else {
console.error(`Error: ${errorMessage}`);
}
process.exit(1);
await handleCommandError(error, 'assets', 'delete', options);
}
});
11 changes: 2 additions & 9 deletions src/commands/assets/get.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Command } from '@cliffy/command';
import { handleCommandError } from '@/lib/errors.ts';
import { formatAsset } from '@/lib/formatters.ts';
import { createAuthenticatedMuxClient } from '@/lib/mux.ts';

Expand All @@ -24,14 +25,6 @@ export const getCommand = new Command()
formatAsset(asset);
}
} catch (error) {
const errorMessage =
error instanceof Error ? error.message : String(error);

if (options.json) {
console.error(JSON.stringify({ error: errorMessage }, null, 2));
} else {
console.error(`Error: ${errorMessage}`);
}
process.exit(1);
await handleCommandError(error, 'assets', 'get', options);
}
});
11 changes: 2 additions & 9 deletions src/commands/assets/input-info.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Command } from '@cliffy/command';
import { handleCommandError } from '@/lib/errors.ts';
import { createAuthenticatedMuxClient } from '@/lib/mux.ts';

interface InputInfoOptions {
Expand Down Expand Up @@ -69,14 +70,6 @@ export const inputInfoCommand = new Command()
}
}
} catch (error) {
const errorMessage =
error instanceof Error ? error.message : String(error);

if (options.json) {
console.error(JSON.stringify({ error: errorMessage }, null, 2));
} else {
console.error(`Error: ${errorMessage}`);
}
process.exit(1);
await handleCommandError(error, 'assets', 'input-info', options);
}
});
11 changes: 2 additions & 9 deletions src/commands/assets/list.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Command } from '@cliffy/command';
import type { Asset } from '@mux/mux-node/resources/video/assets';
import { handleCommandError } from '@/lib/errors.ts';
import {
formatAssetStatus,
formatCreatedAt,
Expand Down Expand Up @@ -85,15 +86,7 @@ export const listCommand = new Command()
}
}
} catch (error) {
const errorMessage =
error instanceof Error ? error.message : String(error);

if (options.json) {
console.error(JSON.stringify({ error: errorMessage }, null, 2));
} else {
console.error(`Error: ${errorMessage}`);
}
process.exit(1);
await handleCommandError(error, 'assets', 'list', options);
}
});

Expand Down
6 changes: 2 additions & 4 deletions src/commands/assets/manage/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Command } from '@cliffy/command';
import { handleCommandError } from '@/lib/errors.ts';
import { createAuthenticatedMuxClient } from '@/lib/mux.ts';

export const manageCommand = new Command()
Expand Down Expand Up @@ -52,9 +53,6 @@ export const manageCommand = new Command()

root.render(React.createElement(AssetManageApp, { mux, onPrompt }));
} catch (error) {
const errorMessage =
error instanceof Error ? error.message : String(error);
console.error(`Error: ${errorMessage}`);
process.exit(1);
await handleCommandError(error, 'assets', 'list', {});
}
});
11 changes: 2 additions & 9 deletions src/commands/assets/playback-ids/create.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Command } from '@cliffy/command';
import { handleCommandError } from '@/lib/errors.ts';
import { createAuthenticatedMuxClient } from '@/lib/mux.ts';
import { createPlaybackId, type PlaybackIdPolicy } from '@/lib/playback-ids.ts';
import { getPlayerUrl, getStreamUrl } from '@/lib/urls.ts';
Expand Down Expand Up @@ -59,14 +60,6 @@ export const createCommand = new Command()
}
}
} catch (error) {
const errorMessage =
error instanceof Error ? error.message : String(error);

if (options.json) {
console.error(JSON.stringify({ error: errorMessage }, null, 2));
} else {
console.error(`Error: ${errorMessage}`);
}
process.exit(1);
await handleCommandError(error, 'assets', 'create', options);
}
});
11 changes: 2 additions & 9 deletions src/commands/assets/playback-ids/delete.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Command } from '@cliffy/command';
import { handleCommandError } from '@/lib/errors.ts';
import { createAuthenticatedMuxClient } from '@/lib/mux.ts';
import { deletePlaybackId } from '@/lib/playback-ids.ts';
import { confirmPrompt } from '@/lib/prompt.ts';
Expand Down Expand Up @@ -46,15 +47,7 @@ export const deleteCommand = new Command()
console.log(`Playback ID ${playbackId} deleted successfully`);
}
} catch (error) {
const errorMessage =
error instanceof Error ? error.message : String(error);

if (options.json) {
console.error(JSON.stringify({ error: errorMessage }, null, 2));
} else {
console.error(`Error: ${errorMessage}`);
}
process.exit(1);
await handleCommandError(error, 'assets', 'delete', options);
}
},
);
11 changes: 2 additions & 9 deletions src/commands/assets/playback-ids/list.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Command } from '@cliffy/command';
import { handleCommandError } from '@/lib/errors.ts';
import { createAuthenticatedMuxClient } from '@/lib/mux.ts';
import { getPlayerUrl, getStreamUrl } from '@/lib/urls.ts';

Expand Down Expand Up @@ -52,14 +53,6 @@ export const listCommand = new Command()
}
}
} catch (error) {
const errorMessage =
error instanceof Error ? error.message : String(error);

if (options.json) {
console.error(JSON.stringify({ error: errorMessage }, null, 2));
} else {
console.error(`Error: ${errorMessage}`);
}
process.exit(1);
await handleCommandError(error, 'assets', 'list', options);
}
});
11 changes: 2 additions & 9 deletions src/commands/assets/static-renditions/create.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Command } from '@cliffy/command';
import type Mux from '@mux/mux-node';
import { handleCommandError } from '@/lib/errors.ts';
import { createAuthenticatedMuxClient } from '@/lib/mux.ts';

type Resolution = NonNullable<
Expand Down Expand Up @@ -85,15 +86,7 @@ export const createCommand = new Command()
outputRendition(rendition, options.json, !options.wait);
}
} catch (error) {
const errorMessage =
error instanceof Error ? error.message : String(error);

if (options.json) {
console.error(JSON.stringify({ error: errorMessage }, null, 2));
} else {
console.error(`Error: ${errorMessage}`);
}
process.exit(1);
await handleCommandError(error, 'assets', 'create', options);
}
});

Expand Down
11 changes: 2 additions & 9 deletions src/commands/assets/static-renditions/delete.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Command } from '@cliffy/command';
import { handleCommandError } from '@/lib/errors.ts';
import { createAuthenticatedMuxClient } from '@/lib/mux.ts';
import { confirmPrompt } from '@/lib/prompt.ts';

Expand Down Expand Up @@ -54,15 +55,7 @@ export const deleteCommand = new Command()
);
}
} catch (error) {
const errorMessage =
error instanceof Error ? error.message : String(error);

if (options.json) {
console.error(JSON.stringify({ error: errorMessage }, null, 2));
} else {
console.error(`Error: ${errorMessage}`);
}
process.exit(1);
await handleCommandError(error, 'assets', 'delete', options);
}
},
);
11 changes: 2 additions & 9 deletions src/commands/assets/static-renditions/list.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Command } from '@cliffy/command';
import type { Asset } from '@mux/mux-node/resources/video/assets';
import { handleCommandError } from '@/lib/errors.ts';
import { createAuthenticatedMuxClient } from '@/lib/mux.ts';

type StaticRenditionFile = NonNullable<
Expand Down Expand Up @@ -43,15 +44,7 @@ export const listCommand = new Command()
}
}
} catch (error) {
const errorMessage =
error instanceof Error ? error.message : String(error);

if (options.json) {
console.error(JSON.stringify({ error: errorMessage }, null, 2));
} else {
console.error(`Error: ${errorMessage}`);
}
process.exit(1);
await handleCommandError(error, 'assets', 'list', options);
}
});

Expand Down
Loading
Loading