drashland / line Goto Github PK
View Code? Open in Web Editor NEWA class-based, command-line interface (CLI) framework for Deno
Home Page: https://drash.land/line
License: MIT License
A class-based, command-line interface (CLI) framework for Deno
Home Page: https://drash.land/line
License: MIT License
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"
};
What:
Make the first release.
Below is a list of tasks that must be completed before this issue can be closed.
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?
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.
Below is a list of tasks that must be completed before this issue can be closed.
public options = {
"--some-cool-option [some_user_defined_wording]": "Some cool option!"
};
A clear and concise summary of 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();
deno run cli.ts
- prints help ✔️deno run cli.ts sub
- prints "A subcommand." ✔️deno run cli.ts sub foo
- prints "[ERROR] Subcommand 'sub' used incorrectly." ✔️deno run cli.ts sub sub
- prints "A subcommand." I would have expected a subcommand name can be written only once, and writing sub sub
would result in "[ERROR] Subcommand 'sub' used incorrectly."
Unsure, I haven't looked at the code.
none
If we decide that options should take in multiple values, then we should think about this as well.
What:
Currently, the option validation for option values only checks to see that the option value was specified:
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.
Below is a list of tasks that must be completed before this issue can be closed.
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
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?
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
Below is a list of tasks that must be completed before this issue can be closed.
// Add example pseudo code for implementation
What:
Currently, the argument validation only checks to see that the arguments were specified:
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.
Below is a list of tasks that must be completed before this issue can be closed.
public signature = "test-creator [test_filename: string] [num_test_cases: number]";
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.
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?
-a
for --all
or -l
for --long
.--long
it would need a value for the getOptionValue
call but sometimes options dont need a value and the option being passed is enough.-h
would halt the logic and present you the help of args and options for that subcommand.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.
Below is a list of tasks that must be completed before this issue can be closed.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.