summaryrefslogtreecommitdiff
blob: 51a1b75d2a7405d4ad6f85ee4feb7dfa63011353 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
<pkgmetadata>
	<herd>haskell</herd>
	<longdescription>
		The @options@ package lets library and application developers easily work
		with command-line options.
		
		The following example is a full program that can accept two options,
		@--message@ and @--quiet@:
		
		@
		import Control.Applicative
		import Options
		
		data MainOptions = MainOptions
		&amp;#x20;   &amp;#x7b; optMessage :: String
		&amp;#x20;   , optQuiet :: Bool
		&amp;#x20;   &amp;#x7d;
		
		instance &#39;Options&#39; MainOptions where
		&amp;#x20;   defineOptions = pure MainOptions
		&amp;#x20;       \&lt;*\&gt; simpleOption \&quot;message\&quot; \&quot;Hello world!\&quot;
		&amp;#x20;           \&quot;A message to show the user.\&quot;
		&amp;#x20;       \&lt;*\&gt; simpleOption \&quot;quiet\&quot; False
		&amp;#x20;           \&quot;Whether to be quiet.\&quot;
		
		main :: IO ()
		main = runCommand $ \\opts args -&gt; do
		&amp;#x20;   if optQuiet opts
		&amp;#x20;       then return ()
		&amp;#x20;       else putStrLn (optMessage opts)
		@
		
		&gt;$ ./hello
		&gt;Hello world!
		&gt;$ ./hello --message=&#39;ciao mondo&#39;
		&gt;ciao mondo
		&gt;$ ./hello --quiet
		&gt;$
		
		In addition, this library will automatically create documentation options
		such as @--help@ and @--help-all@:
		
		&gt;$ ./hello --help
		&gt;Help Options:
		&gt;  -h, --help
		&gt;    Show option summary.
		&gt;  --help-all
		&gt;    Show all help options.
		&gt;
		&gt;Application Options:
		&gt;  --message :: text
		&gt;    A message to show the user.
		&gt;    default: &quot;Hello world!&quot;
		&gt;  --quiet :: bool
		&gt;    Whether to be quiet.
		&gt;    default: false
	</longdescription>
</pkgmetadata>