Git Product home page Git Product logo

line's People

Contributors

crookse avatar drashbot avatar dxu23 avatar ebebbington avatar guergeiro avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

dxu23

line's Issues

Add support for N amount of values for options

Currently, the option with values signature looks like:

public options = {
  "--some-option [value]": "some description"
};

It would be nice to have:

public options = {
  "--some-option [arg_1] [arg_2]": "some description"
};

or even this:

public options = {
"--some-option [...args]": "some description"
};

First Release (v0.1.x)

Summary

What:

Make the first release.

Acceptance Criteria

Below is a list of tasks that must be completed before this issue can be closed.

  • Write documentation
  • Write unit tests
  • Write integration tests

Should the help menu be customizable?

Summary

Should the help menu be customizable? Right now, the help menus are autogenerated by Line and you cannot change the display of the help menu(s). Is there a valid use case for this?

Allow --some-option [value] signature to be --some-option [some_user_defined_wording]

Summary

What:

It was surfaced in Discord that using [value] and not [somethingElse] for an option to take in values was not as clear as it could be. We should make Line's API better by allowing [user_defined_wording] for an option value.

Why:

It's more intuitive.

Acceptance Criteria

Below is a list of tasks that must be completed before this issue can be closed.

  • Write documentation
  • Write unit tests
  • Write integration tests
  • {add more checkboxes required by this issue as needed}

Example Pseudo Code (for implementation)

    public options = {
        "--some-cool-option [some_user_defined_wording]": "Some cool option!"
    };

Subcommands can be written twice during invocation

Summary

A clear and concise summary of the bug.

Steps To Reproduce The Bug

Using this cli.ts

import * as Line from "https://deno.land/x/[email protected]/mod.ts";

class MainCommand extends Line.MainCommand {
    public signature = "main";
    public description = "The main command.";

    public subcommands = [
      Subcommand,
    ];

    public handle(): void {
        console.log("Main command.");
    }
}

class Subcommand extends Line.Subcommand {
    public signature = "sub";
    public description = "A subcommand.";

    public handle() {
        console.log("The subcommand.");
    }
}

// Construct your Line.CLI object and plug in your main command

const cli = new Line.CLI({
    name: "A main command with a subcommand.", // Required config
    description: "To reproduce subcommands being written twice.", // Required config
    version: "v1.0.0", // Required config
    command: MainCommand, // Required config
});

// Run your CLI

cli.run();
  1. deno run cli.ts - prints help ✔️
  2. deno run cli.ts sub - prints "A subcommand." ✔️
  3. deno run cli.ts sub foo - prints "[ERROR] Subcommand 'sub' used incorrectly." ✔️
  4. deno run cli.ts sub sub - prints "A subcommand." ⚠️ 🤔

Expected Behavior

I would have expected a subcommand name can be written only once, and writing sub sub would result in "[ERROR] Subcommand 'sub' used incorrectly."

Suggested Solution(s)

Unsure, I haven't looked at the code.

Screenshots

asciicast

Additional Context

none

Option value "type" validation

If we decide that options should take in multiple values, then we should think about this as well.

Summary

What:

Currently, the option validation for option values only checks to see that the option value was specified:

  • If the value is missing, then an error shows up.

We should do option value validation on the "type" of the option value. For example, I have this option:

public options = {
  "--connections [value: number]": "Add the number of connections"
};

With the above option, Line should check that the value is a number when it parses the option.

Why:

It would be nice to have built-in option value type validation.

Acceptance Criteria

Below is a list of tasks that must be completed before this issue can be closed.

  • Write documentation
  • Write unit tests
  • Write integration tests

Example Pseudo Code (for implementation)

Help Menu

Test Creator - Make test files

USAGE

    test-creator [option]
    test-creator [options] [arg: test_filename] [arg: num_test_cases]

OPTIONS

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

    --connections <number>
        Add the number of connections

Question: Allow arguments to be optional

Allow arguments to be optional?

Question really, thoughts about doing this? Should arguments ever be optional? If something is optional, should an option be used?

Add support for N amount of arguments for a command

Summary

What:

Say my cli has a subcommand where i can do:

$ dmm update deps.ts
$ dmm update fs http
$ dmm update fs http drash
$dmm update deps.ts fs http drash

Where all arugments are optional

What Line should be able to do is allow the user to easily extract those arguments, eg public signature = "update [...modules]

Why:

Right now, i'm using a pure Deno solution to do this, but ideally, Line should be able to provide this for us, making it easier to extract the arguments

Acceptance Criteria

Below is a list of tasks that must be completed before this issue can be closed.

  • Write documentation
  • Write unit tests
  • Write integration tests

Example Pseudo Code (for implementation)

// Add example pseudo code for implementation

Argument "type" validation

Summary

What:

Currently, the argument validation only checks to see that the arguments were specified:

  • If an argument is missing, then an error shows up.
  • If an extra argument was passed in, then an error shows up.

We should do argument validation on the "type" of the argument. For example, I want to make 10 test files using rhum like this:

rhum make 10

With the above command, Line should check that 10 is a number.

Why:

It would be nice to have built-in argument type validation.

Acceptance Criteria

Below is a list of tasks that must be completed before this issue can be closed.

  • Write documentation
  • Write unit tests
  • Write integration tests

Example Pseudo Code (for implementation)

Signature property

public signature = "test-creator [test_filename: string] [num_test_cases: number]";

Help Menu

Test Creator - Make test files

USAGE

    test-creator [option]
    test-creator [arg: test_filename] [arg: num_test_cases]

ARGUMENTS

    test_filename <string>
        The test's filename.
    num_test_cases <number>
        The number of test cases to write in the test file.

OPTIONS

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

Functional improvements to Line

Discussed in https://github.com/drashland/line/discussions/10

Originally posted by kinghat July 22, 2021
i see there are some additions in the pipeline but maybe we could discuss a few more here?

  1. ability to add short names to passed options/flags like -a for --all or -l for --long.
  2. when passing --long it would need a value for the getOptionValue call but sometimes options dont need a value and the option being passed is enough.
  3. being able to get help on an option on a subcommand or the subcommand itself when the subcommand has logic with or without passing args or options. in that case, passing -h would halt the logic and present you the help of args and options for that subcommand.

Support just a main command

Summary

What:

Add support for just a main command that doesn't require subcommands. This should be able to have options as well.

Why:

A user in the discord help channel raised the issue and its a legit use case in my opinion.

Acceptance Criteria

Below is a list of tasks that must be completed before this issue can be closed.

  • Write documentation
  • Write unit tests
  • Write integration tests

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.