-
Notifications
You must be signed in to change notification settings - Fork 6
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
1 parent
97bee99
commit b4b33f9
Showing
118 changed files
with
3,269 additions
and
88 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
name: Build | ||
name: Build sources | ||
on: | ||
push: | ||
paths-ignore: | ||
|
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,99 @@ | ||
name: Build documentation | ||
|
||
on: | ||
push: | ||
branches: ["master"] | ||
pull_request: | ||
|
||
# Gives the workflow permissions to clone the repo and create a page deployment | ||
permissions: | ||
id-token: write | ||
pages: write | ||
|
||
env: | ||
# Name of help module and instance id separated by a slash | ||
INSTANCE: docs/ad | ||
# AD = the ID of the instance in capital letters | ||
ARTIFACT: webHelpAD2-all.zip | ||
# Writerside docker image version | ||
DOCKER_VERSION: 241.15989 | ||
# Add the variable below to upload Algolia indexes | ||
# AD = the ID of the instance in capital letters | ||
ALGOLIA_ARTIFACT: algolia-indexes-AD.zip | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Build Writerside docs using Docker | ||
uses: JetBrains/writerside-github-action@v4 | ||
with: | ||
instance: ${{ env.INSTANCE }} | ||
artifact: ${{ env.ARTIFACT }} | ||
docker-version: ${{ env.DOCKER_VERSION }} | ||
|
||
- name: Upload documentation | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: docs | ||
retention-days: 7 | ||
path: | | ||
artifacts/${{ env.ARTIFACT }} | ||
artifacts/report.json | ||
# Add the step below to upload Algolia indexes | ||
- name: Upload algolia-indexes | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: algolia-indexes | ||
retention-days: 7 | ||
path: artifacts/${{ env.ALGOLIA_ARTIFACT }} | ||
|
||
# fail the build when documentation contains errors | ||
test: | ||
# Requires build job results | ||
needs: build | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Download artifacts | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: docs | ||
path: artifacts | ||
|
||
- name: Test documentation | ||
uses: JetBrains/writerside-checker-action@v1 | ||
with: | ||
instance: ${{ env.INSTANCE }} | ||
|
||
deploy: | ||
if: ${{ github.ref_name == 'master' }} | ||
environment: | ||
name: github-pages | ||
url: ${{ steps.deployment.outputs.page_url }} | ||
# Requires the test job results | ||
needs: test | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Download artifact | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: docs | ||
|
||
- name: Unzip artifact | ||
run: unzip -O UTF-8 -qq ${{ env.ARTIFACT }} -d dir | ||
|
||
- name: Setup Pages | ||
uses: actions/configure-pages@v4 | ||
|
||
- name: Upload artifact | ||
uses: actions/upload-pages-artifact@v3 | ||
with: | ||
path: dir | ||
|
||
- name: Deploy to GitHub Pages | ||
id: deployment | ||
uses: actions/deploy-pages@v4 |
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 |
---|---|---|
|
@@ -3,7 +3,6 @@ | |
out/ | ||
docs.json | ||
__dummy.html | ||
docs/ | ||
/argparse | ||
argparse.iml | ||
*argparse.so | ||
|
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,45 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE instance-profile | ||
SYSTEM "https://resources.jetbrains.com/writerside/1.0/product-profile.dtd"> | ||
|
||
<instance-profile id="ad" | ||
name="argparse documentation" | ||
start-page="Introduction.md"> | ||
|
||
<toc-element topic="Introduction.md"/> | ||
<toc-element topic="Getting-started.md"/> | ||
<toc-element topic="Arguments.md"> | ||
<toc-element topic="Positional-arguments.md"/> | ||
<toc-element topic="Named-arguments.md"> | ||
<toc-element topic="Arguments-bundling.md"/> | ||
<toc-element topic="End-of-named-arguments.md"/> | ||
</toc-element> | ||
<toc-element topic="Supported-types.md"/> | ||
<toc-element topic="Arity.md"/> | ||
<toc-element topic="Optional-and-required-arguments.md"/> | ||
<toc-element topic="Restrict-allowed-values.md"/> | ||
<toc-element topic="Parsing-customization.md"/> | ||
</toc-element> | ||
<toc-element topic="Argument-dependencies.md"/> | ||
<toc-element topic="Calling-the-parser.md"/> | ||
<toc-element topic="ANSI-coloring-and-styling.md"/> | ||
<toc-element topic="Subcommands.md"/> | ||
<toc-element topic="Help-generation.md"/> | ||
<toc-element topic="Shell-completion.md"/> | ||
<toc-element toc-title="Reference"> | ||
<toc-element topic="CLI-API.md"/> | ||
<toc-element topic="Config.md"/> | ||
<toc-element topic="Param-RawParam.md"/> | ||
<toc-element topic="Result.md"/> | ||
<toc-element toc-title="UDAs"> | ||
<toc-element topic="ArgumentGroup.md"/> | ||
<toc-element topic="ArgumentValue.md"/> | ||
<toc-element topic="Command.md"/> | ||
<toc-element topic="MutuallyExclusive.md"/> | ||
<toc-element topic="PositionalNamedArgument.md"/> | ||
<toc-element topic="RequiredTogether.md"/> | ||
</toc-element> | ||
<toc-element topic="SubCommand.md"/> | ||
<toc-element topic="ansiStylingArgument.md"/> | ||
</toc-element> | ||
</instance-profile> |
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,6 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE categories | ||
SYSTEM "https://resources.jetbrains.com/writerside/1.0/categories.dtd"> | ||
<categories> | ||
<category id="wrs" name="Writerside documentation" order="1"/> | ||
</categories> |
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,12 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<buildprofiles xsi:noNamespaceSchemaLocation="https://resources.jetbrains.com/writerside/1.0/build-profiles.xsd" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | ||
|
||
<variables></variables> | ||
<build-profile instance="ad"> | ||
<variables> | ||
<noindex-content>false</noindex-content> | ||
</variables> | ||
</build-profile> | ||
|
||
</buildprofiles> |
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,14 @@ | ||
import argparse; | ||
|
||
struct T | ||
{ | ||
@(NamedArgument.AllowedValues!(["apple","pear","banana"])) | ||
string fruit; | ||
} | ||
|
||
T t; | ||
assert(CLI!T.parseArgs(t, ["--fruit", "apple"])); | ||
assert(t == T("apple")); | ||
|
||
// "kiwi" is not allowed | ||
assert(!CLI!T.parseArgs(t, ["--fruit", "kiwi"])); |
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,20 @@ | ||
import argparse; | ||
|
||
struct T | ||
{ | ||
static auto color = ansiStylingArgument; | ||
} | ||
|
||
T t; | ||
CLI!T.parseArgs(t, ["-h"]); | ||
|
||
// This is a way to detect whether `--color` argument was specified in the command line | ||
// Note that 'autodetect' is converted to either 'on' or 'off' | ||
assert(CLI!T.parseArgs(t, ["--color"])); | ||
assert(t.color); | ||
|
||
assert(CLI!T.parseArgs(t, ["--color=always"])); | ||
assert(t.color); | ||
|
||
assert(CLI!T.parseArgs(t, ["--color=never"])); | ||
assert(!t.color); |
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,13 @@ | ||
import argparse; | ||
|
||
struct T | ||
{ | ||
@(NamedArgument.NumberOfValues(1,3)) | ||
int[] a; | ||
@(NamedArgument.NumberOfValues(2)) | ||
int[] b; | ||
} | ||
|
||
T t; | ||
assert(CLI!T.parseArgs(t, ["-a","1","2","3","-b","4","5"])); | ||
assert(t == T([1,2,3], [4,5])); |
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,19 @@ | ||
import argparse; | ||
|
||
struct T | ||
{ | ||
@(NamedArgument.AllowNoValue !10) int a; | ||
@(NamedArgument.RequireNoValue!20) int b; | ||
} | ||
|
||
T t; | ||
assert(CLI!T.parseArgs(t, ["-a"])); | ||
assert(t.a == 10); | ||
|
||
assert(CLI!T.parseArgs(t, ["-b"])); | ||
assert(t.b == 20); | ||
|
||
assert(CLI!T.parseArgs(t, ["-a","30"])); | ||
assert(t.a == 30); | ||
|
||
assert(!CLI!T.parseArgs(t, ["-b","30"])); // Unrecognized arguments: ["30"] |
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,18 @@ | ||
import argparse; | ||
|
||
struct T | ||
{ | ||
string a; | ||
string b; | ||
} | ||
|
||
mixin CLI!T.main!((args) | ||
{ | ||
// 'args' has 'T' type | ||
static assert(is(typeof(args) == T)); | ||
|
||
// do whatever you need | ||
import std.stdio: writeln; | ||
args.writeln; | ||
return 0; | ||
}); |
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,27 @@ | ||
import argparse; | ||
|
||
struct cmd1 | ||
{ | ||
string a; | ||
} | ||
|
||
struct cmd2 | ||
{ | ||
string b; | ||
} | ||
|
||
mixin CLI!(cmd1, cmd2).main!((args, unparsed) | ||
{ | ||
// 'args' has either 'cmd1' or 'cmd2' type | ||
static if(is(typeof(args) == cmd1)) | ||
writeln("cmd1: ", args); | ||
else static if(is(typeof(args) == cmd2)) | ||
writeln("cmd2: ", args); | ||
else | ||
static assert(false); // this would never happen | ||
|
||
// unparsed arguments has 'string[]' type | ||
static assert(is(typeof(unparsed) == string[])); | ||
|
||
return 0; | ||
}); |
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,21 @@ | ||
import argparse; | ||
|
||
struct COMMAND | ||
{ | ||
string a; | ||
string b; | ||
} | ||
|
||
static int my_main(COMMAND command) | ||
{ | ||
// Do whatever is needed | ||
return 0; | ||
} | ||
|
||
int main(string[] args) | ||
{ | ||
// Do initialization here | ||
// If needed, termination code can be done as 'scope(exit) { ...code... }' here as well | ||
|
||
return CLI!COMMAND.parseArgs!my_main(args[1..$]); | ||
} |
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,19 @@ | ||
import argparse; | ||
|
||
struct COMMAND | ||
{ | ||
string a; | ||
string b; | ||
} | ||
|
||
int main(string[] argv) | ||
{ | ||
COMMAND cmd; | ||
|
||
if(!CLI!COMMAND.parseArgs(cmd, argv[1..$])) | ||
return 1; // parsing failure | ||
|
||
// Do whatever is needed | ||
|
||
return 0; | ||
} |
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,13 @@ | ||
import argparse; | ||
|
||
struct T | ||
{ | ||
string a; | ||
} | ||
|
||
auto arguments = [ "-a", "A", "-c", "C" ]; | ||
|
||
T result; | ||
assert(CLI!T.parseKnownArgs(result, arguments)); | ||
assert(result == T("A")); | ||
assert(arguments == ["-c", "C"]); |
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,18 @@ | ||
import argparse; | ||
|
||
struct T | ||
{ | ||
string a, b; | ||
} | ||
|
||
T t1; | ||
CLI!T.parseArgs(t1, ["-a", "A", "-h", "-b", "B"]); | ||
assert(t1 == T("A")); | ||
|
||
enum Config cfg = { addHelp: false }; | ||
|
||
T t2; | ||
string[] unrecognizedArgs; | ||
CLI!(cfg, T).parseKnownArgs(t2, ["-a", "A", "-h", "-b", "B"], unrecognizedArgs); | ||
assert(t2 == T("A","B")); | ||
assert(unrecognizedArgs == ["-h"]); |
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,16 @@ | ||
import argparse; | ||
|
||
struct T | ||
{ | ||
string[] a; | ||
} | ||
|
||
T t1; | ||
assert(CLI!T.parseArgs(t1, ["-a","1:2:3","-a","4","5"])); | ||
assert(t1 == T(["1:2:3","4","5"])); | ||
|
||
enum Config cfg = { arraySep: ':' }; | ||
|
||
T t2; | ||
assert(CLI!(cfg, T).parseArgs(t2, ["-a","1:2:3","-a","4","5"])); | ||
assert(t2 == T(["1","2","3","4","5"])); |
Oops, something went wrong.