Skip to content

Commit

Permalink
Add initial CLI implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
sophiebremer committed Mar 19, 2024
1 parent 9f982a5 commit 657ca3f
Show file tree
Hide file tree
Showing 25 changed files with 848 additions and 5 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ Examples
--------

```Shell
$ npx tsl-mastodon-cli \
$ npx tsl-mastodon-cli post-status \
--api 'https://mastodon.example/api/v1/' \
--token 'ABC' \
--media 'animation.gif' \
--spoiler 'Hello'
--text 'World'
--text 'Hello, World!' \
--visibiliy public
```


Expand Down
14 changes: 12 additions & 2 deletions bin/tsl-mastodon-cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,17 @@
\*i*i*i*i*i*i*i*i*i*i*i*i*i*i*i*i*i*i*i*i*i*i*i*i*i*i*i*i*i*i*i*i*i*i*i*i*i*i*/


'use strict';


/* *
*
* Import
*
* */


import CLI from '../lib/CLI.js';
import * as CLI from '../lib/index.js';


/* *
Expand All @@ -29,4 +32,11 @@ import CLI from '../lib/CLI.js';
* */


CLI.run( process );
try {
console.info( await CLI.run(
process.argv.slice( process.argv0 === 'node' ? 2 : 0 )
) );
} catch ( error ) {
console.error( error );
process.exit( 1 );
}
20 changes: 20 additions & 0 deletions lib/CLI.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*\
TypeScript Library of the Mastodon CLI
Copyright (c) TypeScriptLibs and Contributors
Licensed under the MIT License.
You may not use this file except in compliance with the License.
You can get a copy of the License at https://typescriptlibs.org/LICENSE.txt
\*i*i*i*i*i*i*i*i*i*i*i*i*i*i*i*i*i*i*i*i*i*i*i*i*i*i*i*i*i*i*i*i*i*i*i*i*i*i*/
export declare const HELP = "\nnpx tsl-mastodon-cli [COMMAND] [OPTIONS]\n\nCOMMAND:\n post-status Posts a status to the timeline.\n\nOPTIONS:\n --api [str] API address of the Mastodon server.\n --api2 [str] API v2 address of the Mastodon server.\n --help -h Show this help.\n --media [str] Media path.\n --text [str] Text string.\n --token [hex] API token.\n --version -v Shows the CLI version.\n --visibility [str] Post visibility: direct, private, public, unlisted.\n\n";
export declare const VERSION: any;
export declare function run(argv: Array<string>): Promise<string>;
declare const _default: {
HELP: string;
VERSION: any;
run: typeof run;
};
export default _default;
98 changes: 98 additions & 0 deletions lib/CLI.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions lib/CLI.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions lib/Status.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*\
TypeScript Library of the Mastodon CLI
Copyright (c) TypeScriptLibs and Contributors
Licensed under the MIT License.
You may not use this file except in compliance with the License.
You can get a copy of the License at https://typescriptlibs.org/LICENSE.txt
\*i*i*i*i*i*i*i*i*i*i*i*i*i*i*i*i*i*i*i*i*i*i*i*i*i*i*i*i*i*i*i*i*i*i*i*i*i*i*/
import * as Types from './Types.js';
export declare function postStatus(context: Types.Context, args: Types.Arguments): Promise<string>;
declare const _default: {
postStatus: typeof postStatus;
};
export default _default;
66 changes: 66 additions & 0 deletions lib/Status.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions lib/Status.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions lib/Types.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*\
TypeScript Library of the Mastodon CLI
Copyright (c) TypeScriptLibs and Contributors
Licensed under the MIT License.
You may not use this file except in compliance with the License.
You can get a copy of the License at https://typescriptlibs.org/LICENSE.txt
\*i*i*i*i*i*i*i*i*i*i*i*i*i*i*i*i*i*i*i*i*i*i*i*i*i*i*i*i*i*i*i*i*i*i*i*i*i*i*/
import * as Mastodon from 'tsl-mastodon-api';
export type Arguments = Record<string, ArgumentValue>;
export type ArgumentValue = (boolean | string | Array<(boolean | string)>);
export interface Context {
api: Mastodon.API;
api2: Mastodon.API;
}
13 changes: 13 additions & 0 deletions lib/Types.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions lib/Types.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 25 additions & 0 deletions lib/Utilities.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*\
TypeScript Library of the Mastodon CLI
Copyright (c) TypeScriptLibs and Contributors
Licensed under the MIT License.
You may not use this file except in compliance with the License.
You can get a copy of the License at https://typescriptlibs.org/LICENSE.txt
\*i*i*i*i*i*i*i*i*i*i*i*i*i*i*i*i*i*i*i*i*i*i*i*i*i*i*i*i*i*i*i*i*i*i*i*i*i*i*/
import * as Types from "./Types.js";
export declare function extractArguments(argv: Array<string>): Types.Arguments;
export declare const info: {
(...data: any[]): void;
(message?: any, ...optionalParams: any[]): void;
};
declare const _default: {
extractArguments: typeof extractArguments;
info: {
(...data: any[]): void;
(message?: any, ...optionalParams: any[]): void;
};
};
export default _default;
65 changes: 65 additions & 0 deletions lib/Utilities.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions lib/Utilities.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 657ca3f

Please sign in to comment.