BadScript 2
Loading...
Searching...
No Matches
Options.cs
Go to the documentation of this file.
1
using
CommandLine
;
2
using
CommandLine.Text
;
3
using
System.Collections.Generic;
4
5
namespace
ReadText.Demo
6
{
7
interface
IOptions
8
{
9
[Option(
'n'
,
"lines"
,
10
Default = 5U,
11
SetName =
"bylines"
,
12
HelpText
=
"Lines to be printed from the beginning or end of the file."
)]
13
uint?
Lines
{
get
;
set
; }
14
15
[Option(
'c'
,
"bytes"
,
16
SetName =
"bybytes"
,
17
HelpText
=
"Bytes to be printed from the beginning or end of the file."
)]
18
uint?
Bytes
{
get
;
set
; }
19
20
[Option(
'q'
,
"quiet"
,
21
HelpText
=
"Suppresses summary messages."
)]
22
bool
Quiet
{
get
;
set
; }
23
24
[Value(0, MetaName =
"input file"
,
25
HelpText
=
"Input file to be processed."
,
26
Required =
true
)]
27
string
FileName
{
get
;
set
; }
28
}
29
30
[Verb(
"head"
,
true
,
HelpText
=
"Displays first lines of a file."
)]
31
class
HeadOptions
:
IOptions
32
{
33
public
uint?
Lines
{
get
;
set
; }
34
35
public
uint?
Bytes
{
get
;
set
; }
36
37
public
bool
Quiet
{
get
;
set
; }
38
39
public
string
FileName
{
get
;
set
; }
40
41
[Usage(ApplicationAlias =
"ReadText.Demo.exe"
)]
42
public
static
IEnumerable<Example>
Examples
43
{
44
get
45
{
46
yield
return
new
Example
(
"normal scenario"
,
new
HeadOptions
{
FileName
=
"file.bin"
});
47
yield
return
new
Example
(
"specify bytes"
,
new
HeadOptions
{
FileName
=
"file.bin"
,
Bytes
=100 });
48
yield
return
new
Example
(
"suppress summary"
,
UnParserSettings
.
WithGroupSwitchesOnly
(),
new
HeadOptions
{ FileName =
"file.bin"
, Quiet = true });
49
yield
return
new
Example
(
"read more lines"
,
new
[] {
UnParserSettings
.
WithGroupSwitchesOnly
(),
UnParserSettings
.
WithUseEqualTokenOnly
() },
new
HeadOptions
{
FileName
=
"file.bin"
,
Lines
= 10 });
50
}
51
}
52
}
53
54
[Verb(
"tail"
,
HelpText
=
"Displays last lines of a file."
)]
55
class
TailOptions
:
IOptions
56
{
57
public
uint?
Lines
{
get
;
set
; }
58
59
public
uint?
Bytes
{
get
;
set
; }
60
61
public
bool
Quiet
{
get
;
set
; }
62
63
public
string
FileName
{
get
;
set
; }
64
}
65
}
CommandLine.Text.Example
Models a command line usage example.
Definition
Example.cs:13
CommandLine.Text.HelpText
Definition
HelpText.cs:33
CommandLine.UnParserSettings
Provides settings for when formatting command line from an options instance../>.
Definition
UnParserExtensions.cs:19
CommandLine.UnParserSettings.WithGroupSwitchesOnly
static UnParserSettings WithGroupSwitchesOnly()
Factory method that creates an instance of CommandLine.UnParserSettings with GroupSwitches set to tru...
Definition
UnParserExtensions.cs:78
CommandLine.UnParserSettings.WithUseEqualTokenOnly
static UnParserSettings WithUseEqualTokenOnly()
Factory method that creates an instance of CommandLine.UnParserSettings with UseEqualToken set to tru...
Definition
UnParserExtensions.cs:88
ReadText.Demo.HeadOptions
Definition
Options.cs:32
ReadText.Demo.HeadOptions.Quiet
bool Quiet
Definition
Options.cs:37
ReadText.Demo.HeadOptions.FileName
string FileName
Definition
Options.cs:39
ReadText.Demo.HeadOptions.Lines
uint? Lines
Definition
Options.cs:33
ReadText.Demo.HeadOptions.Examples
static IEnumerable< Example > Examples
Definition
Options.cs:43
ReadText.Demo.HeadOptions.Bytes
uint? Bytes
Definition
Options.cs:35
ReadText.Demo.TailOptions
Definition
Options.cs:56
ReadText.Demo.TailOptions.FileName
string FileName
Definition
Options.cs:63
ReadText.Demo.TailOptions.Bytes
uint? Bytes
Definition
Options.cs:59
ReadText.Demo.TailOptions.Lines
uint? Lines
Definition
Options.cs:57
ReadText.Demo.TailOptions.Quiet
bool Quiet
Definition
Options.cs:61
ReadText.Demo.IOptions
Definition
Options.cs:8
ReadText.Demo.IOptions.Bytes
uint? Bytes
Definition
Options.cs:18
ReadText.Demo.IOptions.Lines
uint? Lines
Definition
Options.cs:13
ReadText.Demo.IOptions.Quiet
bool Quiet
Definition
Options.cs:22
ReadText.Demo.IOptions.FileName
string FileName
Definition
Options.cs:27
CommandLine.Text
Definition
AssemblyLicenseAttribute.cs:7
CommandLine
Definition
BaseAttribute.cs:8
ReadText.Demo
Definition
Options.cs:6
deps
commandlineparser
demo
ReadText.Demo
Options.cs
Generated by
1.9.8