This repository has been archived by the owner on Aug 20, 2022. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
celicoo
committed
Jul 12, 2019
1 parent
633dd8a
commit 8daa68b
Showing
14 changed files
with
68 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,9 @@ | ||
package docli | ||
|
||
import ( | ||
"os" | ||
"strings" | ||
import "github.com/celicoo/docli/pkg/args" | ||
|
||
"github.com/celicoo/docli/internal/reger" | ||
) | ||
|
||
// Args returns the command-line arguments, starting after the program name. | ||
func Args() (a args) { | ||
// Concatenate the command-line arguments using the U+001F character as | ||
// separator. | ||
s := strings.Join(os.Args[1:], "\u0009") | ||
reger.Build(&a).ParseString(s, &a) | ||
return | ||
// Args returns the AST of the command-line arguments, starting after the | ||
// program name. | ||
func Args() args.Args { | ||
return args.Parse() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package args | ||
|
||
import ( | ||
"os" | ||
"strings" | ||
|
||
"github.com/celicoo/docli/internal/reger" | ||
) | ||
|
||
// args returns the command-line arguments, starting after the program name. | ||
func args() string { | ||
// Concatenate the command-line arguments using the U+001F character as | ||
// separator. | ||
return strings.Join(os.Args[1:], "\u0009") | ||
} | ||
|
||
// Parse returns the AST of the command-line arguments, starting after the | ||
// program name. | ||
func Parse() (a Args) { | ||
// We ignore any errors that might happen when parsing the command-line | ||
// arguments. Although this looks odd, it's preferable over the bad error | ||
// handling of Participle. | ||
reger.Build(&a).ParseString(args(), &a) | ||
return | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package docli | ||
package args | ||
|
||
type command interface { | ||
// Doc returns the doc string of the [command]. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package docli | ||
package args | ||
|
||
import "fmt" | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters