Skip to content

Commit 313657f

Browse files
committed
Use raw strings
1 parent 64550cb commit 313657f

File tree

19 files changed

+402
-322
lines changed

19 files changed

+402
-322
lines changed

eg/NavalFate/Program.cs

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,25 @@
22
using System.Collections.Generic;
33
using DocoptNet;
44

5-
const string help = @"Naval Fate.
6-
7-
Usage:
8-
naval_fate.exe ship new <name>...
9-
naval_fate.exe ship <name> move <x> <y> [--speed=<kn>]
10-
naval_fate.exe ship shoot <x> <y>
11-
naval_fate.exe mine (set|remove) <x> <y> [--moored | --drifting]
12-
naval_fate.exe (-h | --help)
13-
naval_fate.exe --version
14-
15-
Options:
16-
-h --help Show this screen.
17-
--version Show version.
18-
--speed=<kn> Speed in knots [default: 10].
19-
--moored Moored (anchored) mine.
20-
--drifting Drifting mine.
21-
22-
";
5+
const string help = """
6+
Naval Fate.
7+
8+
Usage:
9+
naval_fate.exe ship new <name>...
10+
naval_fate.exe ship <name> move <x> <y> [--speed=<kn>]
11+
naval_fate.exe ship shoot <x> <y>
12+
naval_fate.exe mine (set|remove) <x> <y> [--moored | --drifting]
13+
naval_fate.exe (-h | --help)
14+
naval_fate.exe --version
15+
16+
Options:
17+
-h --help Show this screen.
18+
--version Show version.
19+
--speed=<kn> Speed in knots [default: 10].
20+
--moored Moored (anchored) mine.
21+
--drifting Drifting mine.
22+
23+
""";
2324

2425
var argsParser = Docopt.CreateParser(help).WithVersion("Naval Fate 2.0");
2526

eg/SourceGenerator/ArgumentsExample/Program.cs

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,18 @@ static int Main(ProgramArguments args)
88
foreach (var (name, value) in args)
99
Console.WriteLine($"{name} = {value}");
1010

11-
Console.WriteLine($@"{{
12-
Help = {args.OptHelp},
13-
V = {args.OptV},
14-
Q = {args.OptQ},
15-
R = {args.OptR},
16-
Left = {args.OptLeft},
17-
Right = {args.OptRight},
18-
Correction = {args.ArgCorrection},
19-
File = [{string.Join(", ", args.ArgFile)}],
20-
}}");
11+
Console.WriteLine($$"""
12+
{
13+
Help = {{args.OptHelp}},
14+
V = {{args.OptV}},
15+
Q = {{args.OptQ}},
16+
R = {{args.OptR}},
17+
Left = {{args.OptLeft}},
18+
Right = {{args.OptRight}},
19+
Correction = {{args.ArgCorrection}},
20+
File = [{{string.Join(", ", args.ArgFile)}}],
21+
}
22+
""");
2123

2224
return 0;
2325
}

eg/SourceGenerator/CalculatorExample/Program.cs

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,36 +8,40 @@ static int Main(Arguments args)
88
foreach (var (name, value) in args)
99
Console.WriteLine($"{name} = {value}");
1010

11-
Console.WriteLine($@"{{
12-
Help = {args.OptHelp},
13-
+ = {args.CmdPlus},
14-
- = {args.CmdMinus},
15-
* = {args.CmdStar},
16-
/ = {args.CmdSlash},
17-
Function = {args.ArgFunction},
18-
Comma = {args.CmdComma},
19-
Value = [{string.Join(", ", args.ArgValue)}],
20-
}}");
11+
Console.WriteLine($$"""
12+
{
13+
Help = {{args.OptHelp}},
14+
+ = {{args.CmdPlus}},
15+
- = {{args.CmdMinus}},
16+
* = {{args.CmdStar}},
17+
/ = {{args.CmdSlash}},
18+
Function = {{args.ArgFunction}},
19+
Comma = {{args.CmdComma}},
20+
Value = [{{string.Join(", ", args.ArgValue)}}],
21+
}
22+
""");
2123

2224
return 0;
2325
}
2426

2527
[DocoptArguments]
2628
partial class Arguments
2729
{
28-
public const string Help = @"Not a serious example.
30+
public const string Help = """
31+
Not a serious example.
2932
30-
Usage:
31-
calculator_example.py <value> ( ( + | - | * | / ) <value> )...
32-
calculator_example.py <function> <value> [( , <value> )]...
33-
calculator_example.py (-h | --help)
33+
Usage:
34+
calculator_example.py <value> ( ( + | - | * | / ) <value> )...
35+
calculator_example.py <function> <value> [( , <value> )]...
36+
calculator_example.py (-h | --help)
3437
35-
Examples:
36-
calculator_example.py 1 + 2 + 3 + 4 + 5
37-
calculator_example.py 1 + 2 '*' 3 / 4 - 5 # note quotes around '*'
38-
calculator_example.py sum 10 , 20 , 30 , 40
38+
Examples:
39+
calculator_example.py 1 + 2 + 3 + 4 + 5
40+
calculator_example.py 1 + 2 '*' 3 / 4 - 5 # note quotes around '*'
41+
calculator_example.py sum 10 , 20 , 30 , 40
3942
40-
Options:
41-
-h, --help
42-
";
43+
Options:
44+
-h, --help
45+
46+
""";
4347
}

eg/SourceGenerator/CountedExample/Program.cs

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,29 +8,33 @@ static int Main(Arguments args)
88
foreach (var (name, value) in args)
99
Console.WriteLine($"{name} = {value}");
1010

11-
Console.WriteLine($@"{{
12-
Help = {args.OptHelp},
13-
V = {args.OptV},
14-
Go = {args.CmdGo},
15-
File = [{string.Join(", ", args.ArgFile)}],
16-
Path = {args.OptPath},
17-
}}");
11+
Console.WriteLine($$"""
12+
{
13+
Help = {{args.OptHelp}},
14+
V = {{args.OptV}},
15+
Go = {{args.CmdGo}},
16+
File = [{{string.Join(", ", args.ArgFile)}}],
17+
Path = {{args.OptPath}},
18+
}
19+
""");
1820

1921
return 0;
2022
}
2123

2224
[DocoptArguments]
2325
partial class Arguments
2426
{
25-
public const string Help = @"Usage: CountedExample --help
26-
CountedExample -v...
27-
CountedExample go [go]
28-
CountedExample (--path=<path>)...
29-
CountedExample <file> <file>
27+
public const string Help = """
28+
Usage: CountedExample --help
29+
CountedExample -v...
30+
CountedExample go [go]
31+
CountedExample (--path=<path>)...
32+
CountedExample <file> <file>
3033
31-
Try: CountedExample -vvvvvvvvvv
32-
CountedExample go go
33-
CountedExample --path ./here --path ./there
34-
CountedExample this.txt that.txt
35-
";
34+
Try: CountedExample -vvvvvvvvvv
35+
CountedExample go go
36+
CountedExample --path ./here --path ./there
37+
CountedExample this.txt that.txt
38+
39+
""";
3640
}

eg/SourceGenerator/NavalFate/Program.cs

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,25 @@ static int Main(ProgramArguments args)
1010
foreach (var (name, value) in args)
1111
Console.WriteLine($"{name} = {value}");
1212

13-
Console.WriteLine($@"{{
14-
Ship = {args.CmdShip },
15-
New = {args.CmdNew },
16-
Name = [{string.Join(", ", args.ArgName)}],
17-
Move = {args.CmdMove },
18-
X = {args.ArgX },
19-
Y = {args.ArgY },
20-
Speed = {args.OptSpeed },
21-
Shoot = {args.CmdShoot },
22-
Mine = {args.CmdMine },
23-
Set = {args.CmdSet },
24-
Remove = {args.CmdRemove },
25-
Moored = {args.OptMoored },
26-
Drifting = {args.OptDrifting},
27-
Help = {args.OptHelp },
28-
Version = {args.OptVersion },
29-
}}");
13+
Console.WriteLine($$"""
14+
{
15+
Ship = {{args.CmdShip }},
16+
New = {{args.CmdNew }},
17+
Name = [{{string.Join(", ", args.ArgName)}}],
18+
Move = {{args.CmdMove }},
19+
X = {{args.ArgX }},
20+
Y = {{args.ArgY }},
21+
Speed = {{args.OptSpeed }},
22+
Shoot = {{args.CmdShoot }},
23+
Mine = {{args.CmdMine }},
24+
Set = {{args.CmdSet }},
25+
Remove = {{args.CmdRemove }},
26+
Moored = {{args.OptMoored }},
27+
Drifting = {{args.OptDrifting}},
28+
Help = {{args.OptHelp }},
29+
Version = {{args.OptVersion }},
30+
}
31+
""");
3032

3133
return 0;
3234
}

eg/SourceGenerator/OddEvenExample/Program.cs

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,28 @@ static int Main(Arguments args)
88
foreach (var (name, value) in args)
99
Console.WriteLine($"{name} = {value}");
1010

11-
Console.WriteLine($@"{{
12-
Help = {args.OptHelp},
13-
Odd = [{string.Join(", ", args.ArgOdd)}],
14-
Even = [{string.Join(", ", args.ArgEven)}],
15-
}}");
11+
Console.WriteLine($$"""
12+
{
13+
Help = {{args.OptHelp}},
14+
Odd = [{{string.Join(", ", args.ArgOdd)}}],
15+
Even = [{{string.Join(", ", args.ArgEven)}}],
16+
}
17+
""");
1618

1719
return 0;
1820
}
1921

2022
[DocoptArguments]
2123
partial class Arguments
2224
{
23-
public const string Help = @"Usage: OddEvenExample [-h | --help] (ODD EVEN)...
25+
public const string Help = """
26+
Usage: OddEvenExample [-h | --help] (ODD EVEN)...
2427
25-
Example, try:
26-
OddEvenExample 1 2 3 4
28+
Example, try:
29+
OddEvenExample 1 2 3 4
2730
28-
Options:
29-
-h, --help
30-
";
31+
Options:
32+
-h, --help
33+
34+
""";
3135
}

eg/SourceGenerator/OptionsExample/Program.cs

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,26 @@ static int Main(ProgramArguments args)
1010
foreach (var (name, value) in args)
1111
Console.WriteLine($"{name} = {value}");
1212

13-
Console.WriteLine($@"{{
14-
Help = {args.OptHelp },
15-
Verbose = {args.OptVerbose },
16-
Quiet = {args.OptQuiet },
17-
Repeat = {args.OptRepeat },
18-
File = {args.OptFile },
19-
Exclude = {args.OptExclude },
20-
Select = {args.OptSelect },
21-
Ignore = {args.OptIgnore },
22-
ShowSource = {args.OptShowSource},
23-
Statistics = {args.OptStatistics},
24-
Count = {args.OptCount },
25-
Benchmark = {args.OptBenchmark },
26-
Path = [{string.Join(", ", args.ArgPath)}],
27-
Doctest = {args.OptDoctest },
28-
Testsuite = {args.OptTestsuite },
29-
Version = {args.OptVersion },
30-
}}");
13+
Console.WriteLine($$"""
14+
{
15+
Help = {{args.OptHelp }},
16+
Verbose = {{args.OptVerbose }},
17+
Quiet = {{args.OptQuiet }},
18+
Repeat = {{args.OptRepeat }},
19+
File = {{args.OptFile }},
20+
Exclude = {{args.OptExclude }},
21+
Select = {{args.OptSelect }},
22+
Ignore = {{args.OptIgnore }},
23+
ShowSource = {{args.OptShowSource}},
24+
Statistics = {{args.OptStatistics}},
25+
Count = {{args.OptCount }},
26+
Benchmark = {{args.OptBenchmark }},
27+
Path = [{{string.Join(", ", args.ArgPath)}}],
28+
Doctest = {{args.OptDoctest }},
29+
Testsuite = {{args.OptTestsuite }},
30+
Version = {{args.OptVersion }},
31+
}
32+
""");
3133

3234
return 0;
3335
}

eg/SourceGenerator/OptionsShortcutExample/Program.cs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,17 @@ static int Main(ProgramArguments args)
1010
foreach (var (name, value) in args)
1111
Console.WriteLine($"{name} = {value}");
1212

13-
Console.WriteLine($@"{{
14-
Help = {args.OptHelp },
15-
Version = {args.OptVersion},
16-
Number = {args.OptNumber },
17-
Timeout = {args.OptTimeout},
18-
Apply = {args.OptApply },
19-
Q = {args.OptQ },
20-
Port = {args.ArgPort },
21-
}}");
13+
Console.WriteLine($$"""
14+
{
15+
Help = {{args.OptHelp }},
16+
Version = {{args.OptVersion}},
17+
Number = {{args.OptNumber }},
18+
Timeout = {{args.OptTimeout}},
19+
Apply = {{args.OptApply }},
20+
Q = {{args.OptQ }},
21+
Port = {{args.ArgPort }},
22+
}
23+
""");
2224

2325
return 0;
2426
}

eg/SourceGenerator/QuickExample/Program.cs

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,27 +10,31 @@ static int Main(Arguments args)
1010
foreach (var (name, value) in args)
1111
Console.WriteLine($"{name} = {value}");
1212

13-
Console.WriteLine($@"{{
14-
Tcp = {args.CmdTcp },
15-
Host = {args.ArgHost },
16-
Port = {args.ArgPort },
17-
Timeout = {args.OptTimeout},
18-
Serial = {args.CmdSerial },
19-
Baud = {args.OptBaud },
20-
H = {args.OptH },
21-
Help = {args.OptHelp },
22-
Version = {args.OptVersion},
23-
}}");
13+
Console.WriteLine($$"""
14+
{
15+
Tcp = {{args.CmdTcp }},
16+
Host = {{args.ArgHost }},
17+
Port = {{args.ArgPort }},
18+
Timeout = {{args.OptTimeout}},
19+
Serial = {{args.CmdSerial }},
20+
Baud = {{args.OptBaud }},
21+
H = {{args.OptH }},
22+
Help = {{args.OptHelp }},
23+
Version = {{args.OptVersion}},
24+
}
25+
""");
2426

2527
return 0;
2628
}
2729

2830
[DocoptArguments]
2931
partial class Arguments
3032
{
31-
public const string Help = @"Usage:
32-
QuickExample tcp <host> <port> [--timeout=<seconds>]
33-
QuickExample serial <port> [--baud=9600] [--timeout=<seconds>]
34-
QuickExample -h | --help | --version
35-
";
33+
public const string Help = """
34+
Usage:
35+
QuickExample tcp <host> <port> [--timeout=<seconds>]
36+
QuickExample serial <port> [--baud=9600] [--timeout=<seconds>]
37+
QuickExample -h | --help | --version
38+
39+
""";
3640
}

0 commit comments

Comments
 (0)