Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V1 #13

Merged
merged 55 commits into from Dec 12, 2021
Merged

V1 #13

merged 55 commits into from Dec 12, 2021

Conversation

crookse
Copy link
Member

@crookse crookse commented Dec 2, 2021

Closes #11
Closes #5

Notes

  • Introduces v1
  • Code is exercised via integration tests (there aren't any unit tests). Should we add unit tests or do the integration tests suffice so far?
  • New readme to match Drash: https://github.com/drashland/line/tree/v1

How to create a CLI

There is something that is bothering me. Right now, to describe an argument, you have to provide an arguments object. For example:

class MyCommand extends Line.MainCommand {
  public signature = "line [arg]";

+  public arguments = {
+    "arg": "Some description.",
+  };

  public async handle(): Promise<void> {
    console.log("sup");
  }
}

const cli = new Line.Cli({
  name: "My Cool CLI",
  description: "My cool description",
  version: "v1.0.0",
  command: MyCommand,
});

cli.run();

And when you run it, it outputs the following:

My Cool CLI - My cool description

USAGE

    line [option]
    line [arg: arg]

ARGUMENTS

    arg
+        Some description.

OPTIONS

    -h, --help
        Show this menu.
    -v, --version
        Show this CLI's version.

I feel like arguments is a weird property name. Maybe argument_descriptions? I wouldn't say descriptions, because the options property also contains descriptions (the value is the description of the option(s)), so it's kind of confusing in that regard. Thoughts though?

TODO

  • Change arguments description object?
  • Documentation

crookse and others added 30 commits August 7, 2021 08:54
* This commit introduces a main command. The main command is in charge of defining subcommands now.
* Line is now Cli
* Subcommand options are defined through a key-value pair object
* CommandLine has been refactored to handle the restructure
If a main command takes in args, then it can't have subcommands
Refactored the following:
* options getting
* argument getting
* options parsing
* argument parsing
* help menus
* command and subcommand validation
@crookse crookse added the Type: Major Merging this pull request results in a major version increment label Dec 2, 2021
Copy link
Member

@ebebbington ebebbington left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Beautiful

@crookse crookse merged commit 8c700b1 into main Dec 12, 2021
@crookse crookse deleted the v1 branch December 12, 2021 13:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Major Merging this pull request results in a major version increment
Development

Successfully merging this pull request may close these issues.

Functional improvements to Line Support just a main command
2 participants