Skip to content

Commit

Permalink
Fixed the trailing arguments with quotes.
Browse files Browse the repository at this point in the history
  • Loading branch information
fenying committed Apr 5, 2019
1 parent 56562c1 commit 6679477
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
6 changes: 4 additions & 2 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@

[Dep:LRT.Core]: https://github.com/litert/core.js

## v1.0.1

- Fixed: The trailing arguments after `--` should be wrapped by quotes.

## v1.0.0

- Upgraded [`@litert/core`][Dep:LRT.Core] to the v1.0.x.
- Refactored the APIs, for more easier usage.
- Added `windows` style options supports.
- Added `go` style options supports.
- Added unlimited commands supports.

## v0.2.2
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@litert/clap",
"version": "1.0.0",
"version": "1.0.1",
"description": "A simple library for parsing commandline arguments.",
"main": "./lib/index.js",
"scripts": {
Expand Down
6 changes: 5 additions & 1 deletion src/lib/GNUParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,11 @@ class GNUParser extends AbstractParser {
pos,
-2,
"--",
args.splice(pos, args.length - pos).slice(1).join(" ")
args.splice(
pos, args.length - pos
).map(
(x) => `"${x}"`
).slice(1).join(" ")
);
}

Expand Down
2 changes: 1 addition & 1 deletion src/samples/02-command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ parser.addOption({
console.log(JSON.stringify(
parser.parse([
"help", "login", "-u=fenying", "-p=helloworld!", "-vcfff",
"--", "--username=fff", "--ccc=12313"
"--", "--username=fff", "--ccc=12313", "this is a test"
]),
null,
2
Expand Down

0 comments on commit 6679477

Please sign in to comment.