Skip to content

Commit

Permalink
feat: dropping our position system for ordering commands in --help (
Browse files Browse the repository at this point in the history
  • Loading branch information
erunion authored Dec 9, 2022
1 parent 971316a commit 75aaba2
Show file tree
Hide file tree
Showing 30 changed files with 10 additions and 70 deletions.
14 changes: 7 additions & 7 deletions __tests__/__snapshots__/index.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ Options
Related commands
$ rdme openapi:reduce Reduce an OpenAPI definition into a smaller subset.
$ rdme openapi:validate Validate your OpenAPI/Swagger definition.
$ rdme openapi:inspect Analyze an OpenAPI/Swagger definition for various OpenAPI and ReadMe
feature usage.
$ rdme openapi:reduce Reduce an OpenAPI definition into a smaller subset.
$ rdme openapi:validate Validate your OpenAPI/Swagger definition.
"
`;

Expand Down Expand Up @@ -67,10 +67,10 @@ Options
Related commands
$ rdme openapi:reduce Reduce an OpenAPI definition into a smaller subset.
$ rdme openapi:validate Validate your OpenAPI/Swagger definition.
$ rdme openapi:inspect Analyze an OpenAPI/Swagger definition for various OpenAPI and ReadMe
feature usage.
$ rdme openapi:reduce Reduce an OpenAPI definition into a smaller subset.
$ rdme openapi:validate Validate your OpenAPI/Swagger definition.
"
`;

Expand Down Expand Up @@ -104,10 +104,10 @@ Options
Related commands
$ rdme openapi:reduce Reduce an OpenAPI definition into a smaller subset.
$ rdme openapi:validate Validate your OpenAPI/Swagger definition.
$ rdme openapi:inspect Analyze an OpenAPI/Swagger definition for various OpenAPI and ReadMe
feature usage.
$ rdme openapi:reduce Reduce an OpenAPI definition into a smaller subset.
$ rdme openapi:validate Validate your OpenAPI/Swagger definition.
"
`;
Expand All @@ -128,7 +128,7 @@ Options
Related commands
$ rdme versions:create Create a new version for your project.
$ rdme versions:update Update an existing version for your project.
$ rdme versions:delete Delete a version associated with your ReadMe project.
$ rdme versions:update Update an existing version for your project.
"
`;
24 changes: 0 additions & 24 deletions __tests__/lib/__snapshots__/commands.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,16 @@ exports[`utils #listByCategory should list commands by category 1`] = `
"description": "Login to a ReadMe project.",
"hidden": false,
"name": "login",
"position": 1,
},
{
"description": "Logs the currently authenticated user out of ReadMe.",
"hidden": false,
"name": "logout",
"position": 2,
},
{
"description": "Displays the current user and project authenticated with ReadMe.",
"hidden": false,
"name": "whoami",
"position": 3,
},
],
"description": "Administration",
Expand All @@ -31,37 +28,31 @@ exports[`utils #listByCategory should list commands by category 1`] = `
"description": "Upload, or resync, your OpenAPI/Swagger definition to ReadMe.",
"hidden": false,
"name": "openapi",
"position": 1,
},
{
"description": "Analyze an OpenAPI/Swagger definition for various OpenAPI and ReadMe feature usage.",
"hidden": false,
"name": "openapi:inspect",
"position": 4,
},
{
"description": "Reduce an OpenAPI definition into a smaller subset.",
"hidden": false,
"name": "openapi:reduce",
"position": 2,
},
{
"description": "Validate your OpenAPI/Swagger definition.",
"hidden": false,
"name": "openapi:validate",
"position": 3,
},
{
"description": "Alias for \`rdme openapi\`. [deprecated]",
"hidden": true,
"name": "swagger",
"position": 4,
},
{
"description": "Alias for \`rdme openapi:validate\` [deprecated].",
"hidden": true,
"name": "validate",
"position": 5,
},
],
"description": "OpenAPI / Swagger",
Expand All @@ -72,13 +63,11 @@ exports[`utils #listByCategory should list commands by category 1`] = `
"description": "Get all categories in your ReadMe project.",
"hidden": false,
"name": "categories",
"position": 1,
},
{
"description": "Create a category with the specified title and guide in your ReadMe project.",
"hidden": false,
"name": "categories:create",
"position": 2,
},
],
"description": "Categories",
Expand All @@ -89,7 +78,6 @@ exports[`utils #listByCategory should list commands by category 1`] = `
"description": "Sync Markdown files to your ReadMe project as Changelog posts. Can either be a path to a directory or a single Markdown file.",
"hidden": false,
"name": "changelogs",
"position": 1,
},
],
"description": "Changelog",
Expand All @@ -100,7 +88,6 @@ exports[`utils #listByCategory should list commands by category 1`] = `
"description": "Sync Markdown/HTML files to your ReadMe project as Custom Pages. Can either be a path to a directory or a single Markdown/HTML file.",
"hidden": false,
"name": "custompages",
"position": 1,
},
],
"description": "Custom Pages",
Expand All @@ -111,31 +98,26 @@ exports[`utils #listByCategory should list commands by category 1`] = `
"description": "Sync Markdown files to your ReadMe project as Guides. Can either be a path to a directory or a single Markdown file.",
"hidden": false,
"name": "docs",
"position": 1,
},
{
"description": "Delete any docs from ReadMe if their slugs are not found in the target folder.",
"hidden": false,
"name": "docs:prune",
"position": 2,
},
{
"description": "Edit a single file from your ReadMe project without saving locally. [deprecated]",
"hidden": true,
"name": "docs:edit",
"position": 3,
},
{
"description": "Alias for \`rdme docs\`.",
"hidden": false,
"name": "guides",
"position": 3,
},
{
"description": "Alias for \`rdme docs:prune\`.",
"hidden": false,
"name": "guides:prune",
"position": 4,
},
],
"description": "Docs (a.k.a. Guides)",
Expand All @@ -146,13 +128,11 @@ exports[`utils #listByCategory should list commands by category 1`] = `
"description": "Helpful OpenAPI generation tooling. [inactive]",
"hidden": true,
"name": "oas",
"position": 2,
},
{
"description": "Open your current ReadMe project in the browser.",
"hidden": false,
"name": "open",
"position": 1,
},
],
"description": "Other useful commands",
Expand All @@ -163,25 +143,21 @@ exports[`utils #listByCategory should list commands by category 1`] = `
"description": "List versions available in your project or get a version by SemVer (https://semver.org/).",
"hidden": false,
"name": "versions",
"position": 1,
},
{
"description": "Create a new version for your project.",
"hidden": false,
"name": "versions:create",
"position": 2,
},
{
"description": "Delete a version associated with your ReadMe project.",
"hidden": false,
"name": "versions:delete",
"position": 4,
},
{
"description": "Update an existing version for your project.",
"hidden": false,
"name": "versions:update",
"position": 3,
},
],
"description": "Versions",
Expand Down
5 changes: 1 addition & 4 deletions __tests__/lib/commands.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ describe('utils', () => {
expect(cmd.usage).toStartWith(cmd.command);
expect(cmd.description).not.toBeEmpty();
expect(cmd.cmdCategory).not.toBeEmpty();
expect(cmd.position).toBeNumber();
expect(cmd.args).toBeArray();
expect(cmd.run).toBeFunction();

Expand All @@ -36,7 +35,7 @@ describe('utils', () => {
});

describe('cli standards', () => {
describe.each<[string, Command]>(commands.list().map(cmd => [cmd.command.command, cmd.command]))(
describe.each<[string, Command]>(commands.list().map(cmd => [cmd.command.command, cmd.command as Command]))(
'%s',
(_, command) => {
it('should have a description that ends with punctuation', () => {
Expand Down Expand Up @@ -94,13 +93,11 @@ describe('utils', () => {
{
name: 'logout',
description: 'Logs the currently authenticated user out of ReadMe.',
position: 2,
hidden: false,
},
{
name: 'whoami',
description: 'Displays the current user and project authenticated with ReadMe.',
position: 3,
hidden: false,
},
]);
Expand Down
1 change: 0 additions & 1 deletion src/cmds/categories/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ export default class CategoriesCreateCommand extends Command {
this.usage = 'categories:create <title> [options]';
this.description = 'Create a category with the specified title and guide in your ReadMe project.';
this.cmdCategory = CommandCategories.CATEGORIES;
this.position = 2;

this.hiddenArgs = ['title'];
this.args = [
Expand Down
1 change: 0 additions & 1 deletion src/cmds/categories/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ export default class CategoriesCommand extends Command {
this.usage = 'categories [options]';
this.description = 'Get all categories in your ReadMe project.';
this.cmdCategory = CommandCategories.CATEGORIES;
this.position = 1;

this.args = [this.getKeyArg(), this.getVersionArg()];
}
Expand Down
1 change: 0 additions & 1 deletion src/cmds/changelogs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ export default class ChangelogsCommand extends Command {
this.description =
'Sync Markdown files to your ReadMe project as Changelog posts. Can either be a path to a directory or a single Markdown file.';
this.cmdCategory = CommandCategories.CHANGELOGS;
this.position = 1;

this.hiddenArgs = ['filePath'];
this.args = [
Expand Down
1 change: 0 additions & 1 deletion src/cmds/custompages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ export default class CustomPagesCommand extends Command {
this.description =
'Sync Markdown/HTML files to your ReadMe project as Custom Pages. Can either be a path to a directory or a single Markdown/HTML file.';
this.cmdCategory = CommandCategories.CUSTOM_PAGES;
this.position = 1;

this.hiddenArgs = ['filePath'];
this.args = [
Expand Down
1 change: 0 additions & 1 deletion src/cmds/docs/edit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ export default class DocsEditCommand extends Command {
this.usage = 'docs:edit <slug> [options]';
this.description = 'Edit a single file from your ReadMe project without saving locally. [deprecated]';
this.cmdCategory = CommandCategories.DOCS;
this.position = 3;

this.hiddenArgs = ['slug'];
this.args = [
Expand Down
1 change: 0 additions & 1 deletion src/cmds/docs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ export default class DocsCommand extends Command {
this.description =
'Sync Markdown files to your ReadMe project as Guides. Can either be a path to a directory or a single Markdown file.';
this.cmdCategory = CommandCategories.DOCS;
this.position = 1;

this.hiddenArgs = ['filePath'];
this.args = [
Expand Down
1 change: 0 additions & 1 deletion src/cmds/docs/prune.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ export default class DocsPruneCommand extends Command {
this.usage = 'docs:prune <folder> [options]';
this.description = 'Delete any docs from ReadMe if their slugs are not found in the target folder.';
this.cmdCategory = CommandCategories.DOCS;
this.position = 2;

this.hiddenArgs = ['folder'];
this.args = [
Expand Down
1 change: 0 additions & 1 deletion src/cmds/guides/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ export default class GuidesCommand extends DocsCommand {
this.command = 'guides';
this.usage = 'guides <path> [options]';
this.description = 'Alias for `rdme docs`.';
this.position = 3;
}

async run(opts: CommandOptions<Options>) {
Expand Down
1 change: 0 additions & 1 deletion src/cmds/guides/prune.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ export default class GuidesPruneCommand extends DocsPruneCommand {
this.command = 'guides:prune';
this.usage = 'guides:prune <folder> [options]';
this.description = 'Alias for `rdme docs:prune`.';
this.position = 4;
}

async run(opts: CommandOptions<Options>) {
Expand Down
1 change: 0 additions & 1 deletion src/cmds/login.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ export default class LoginCommand extends Command {
this.usage = 'login [options]';
this.description = 'Login to a ReadMe project.';
this.cmdCategory = CommandCategories.ADMIN;
this.position = 1;

this.args = [
{
Expand Down
1 change: 0 additions & 1 deletion src/cmds/logout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ export default class LogoutCommand extends Command {
this.usage = 'logout';
this.description = 'Logs the currently authenticated user out of ReadMe.';
this.cmdCategory = CommandCategories.ADMIN;
this.position = 2;

this.args = [];
}
Expand Down
1 change: 0 additions & 1 deletion src/cmds/oas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ export default class OASCommand extends Command {
this.usage = 'oas';
this.description = 'Helpful OpenAPI generation tooling. [inactive]';
this.cmdCategory = CommandCategories.UTILITIES;
this.position = 2;

this.args = [];
}
Expand Down
1 change: 0 additions & 1 deletion src/cmds/open.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ export default class OpenCommand extends Command {
this.usage = 'open';
this.description = 'Open your current ReadMe project in the browser.';
this.cmdCategory = CommandCategories.UTILITIES;
this.position = 1;

this.args = [
{
Expand Down
1 change: 0 additions & 1 deletion src/cmds/openapi/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ export default class OpenAPICommand extends Command {
this.usage = 'openapi [file|url] [options]';
this.description = 'Upload, or resync, your OpenAPI/Swagger definition to ReadMe.';
this.cmdCategory = CommandCategories.APIS;
this.position = 1;

this.hiddenArgs = ['spec'];
this.args = [
Expand Down
1 change: 0 additions & 1 deletion src/cmds/openapi/inspect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ export default class OpenAPIInspectCommand extends Command {
this.usage = 'openapi:inspect [file|url] [options]';
this.description = 'Analyze an OpenAPI/Swagger definition for various OpenAPI and ReadMe feature usage.';
this.cmdCategory = CommandCategories.APIS;
this.position = 4;

this.hiddenArgs = ['spec'];
this.args = [
Expand Down
1 change: 0 additions & 1 deletion src/cmds/openapi/reduce.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ export default class OpenAPIReduceCommand extends Command {
this.usage = 'openapi:reduce [file|url] [options]';
this.description = 'Reduce an OpenAPI definition into a smaller subset.';
this.cmdCategory = CommandCategories.APIS;
this.position = 2;

this.hiddenArgs = ['spec'];
this.args = [
Expand Down
1 change: 0 additions & 1 deletion src/cmds/openapi/validate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ export default class OpenAPIValidateCommand extends Command {
this.usage = 'openapi:validate [file|url] [options]';
this.description = 'Validate your OpenAPI/Swagger definition.';
this.cmdCategory = CommandCategories.APIS;
this.position = 3;

this.hiddenArgs = ['spec'];
this.args = [
Expand Down
1 change: 0 additions & 1 deletion src/cmds/swagger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ export default class SwaggerCommand extends OpenAPICommand {
this.command = 'swagger';
this.usage = 'swagger [file] [options]';
this.description = 'Alias for `rdme openapi`. [deprecated]';
this.position = 4;
}

async run(opts: CommandOptions<Options>) {
Expand Down
1 change: 0 additions & 1 deletion src/cmds/validate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ export default class ValidateAliasCommand extends OpenAPIValidateCommand {
this.command = 'validate';
this.usage = 'validate [file] [options]';
this.description = 'Alias for `rdme openapi:validate` [deprecated].';
this.position = 5;
}

async run(opts: CommandOptions<Options>) {
Expand Down
1 change: 0 additions & 1 deletion src/cmds/versions/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ export default class CreateVersionCommand extends Command {
this.usage = 'versions:create <version> [options]';
this.description = 'Create a new version for your project.';
this.cmdCategory = CommandCategories.VERSIONS;
this.position = 2;

this.hiddenArgs = ['version'];
this.args = [
Expand Down
Loading

0 comments on commit 75aaba2

Please sign in to comment.