dev-haskell/hflags (haskell)

Search

Package Information

Description:
The @HFlags@ library supports easy definition of command line flags, reimplementing the ideas from Google's @gflags@ (<http://code.google.com/p/gflags>). Command line flags can be declared in any file at the toplevel, using 'defineFlag'. At runtime, the actual values are assigned to the toplevel @flags_name@ constants. Those can be used purely throughout the program. At the beginning of the @main@ function, @$initHFlags \"program description\"@ has to be called to initialize the flags. All flags will be initialized that are transitively reachable via imports from @main@. This means, that any Haskell package can easily define command line flags with @HFlags@. This feature is demonstrated by <http://github.com/errge/hflags/blob/master/examples/ImportExample.hs> and <http://github.com/errge/hflags/tree/master/examples/package>. A simple example (more in the <http://github.com/errge/hflags/tree/master/examples> directory): @ \#!\/usr\/bin\/env runhaskell {-\# LANGUAGE TemplateHaskell \#-} import HFlags 'defineFlag' \"name\" \"Indiana Jones\" \"Who to greet.\" 'defineFlag' \"r:repeat\" (3 + 4 :: Int) \"Number of times to repeat the message.\" main = do s <- $initHFlags \"Simple program v0.1\"   sequence_ $ replicate flags_repeat greet   putStrLn $ \"Your additional arguments were: \" ++ show s   putStrLn $ \"Which is the same as: \" ++ show HFlags.arguments   where   greet = putStrLn $ \"Hello \" ++ flags_name ++ \", very nice to meet you!\" @ At @initHFlags@ time, the library also tries to gather flags out of environment variables. @HFLAGS_verbose=True@ is equivalent to specify --verbose=True. This environment feature only works with long options and the user has to specify a value even for Bools. /Since version 0.2, you mustn't put the initHFlags in a parentheses with the program description. Just/ @$initHFlags@, /it's cleaner./ See <http://github.com/errge/hflags/tree/master/changelog> for recent changes.
Homepage:
https://github.com/errge/hflags
License:
Apache-2.0

Versions

Version EAPI Keywords Slot
0.4.3 8 ~amd64 0/0.4.3

Metadata

Description

Maintainers

Raw Metadata XML
<pkgmetadata>
	<maintainer type="project">
		<email>haskell@gentoo.org</email>
		<name>Gentoo Haskell</name>
	</maintainer>
	<longdescription>
		The @HFlags@ library supports easy definition of command line flags,
		reimplementing the ideas from Google's @gflags@
		(&lt;http://code.google.com/p/gflags&gt;).
		
		Command line flags can be declared in any file at the toplevel,
		using 'defineFlag'.  At runtime, the actual values are assigned to
		the toplevel @flags_name@ constants.  Those can be used purely
		throughout the program.
		
		At the beginning of the @main@ function, @$initHFlags \"program
		description\"@ has to be called to initialize the flags.  All flags
		will be initialized that are transitively reachable via imports from
		@main@.  This means, that any Haskell package can easily define
		command line flags with @HFlags@.  This feature is demonstrated by
		&lt;http://github.com/errge/hflags/blob/master/examples/ImportExample.hs&gt;
		and &lt;http://github.com/errge/hflags/tree/master/examples/package&gt;.
		
		A simple example (more in the
		&lt;http://github.com/errge/hflags/tree/master/examples&gt; directory):
		
		@
		\#!\/usr\/bin\/env runhaskell
		
		&amp;#x7b;-\# LANGUAGE TemplateHaskell \#-&amp;#x7d;
		
		import HFlags
		
		'defineFlag' \"name\" \"Indiana Jones\" \"Who to greet.\"
		'defineFlag' \"r:repeat\" (3 + 4 :: Int) \"Number of times to repeat the message.\"
		
		main = do s &lt;- $initHFlags \"Simple program v0.1\"
		&amp;#x20;         sequence_ $ replicate flags_repeat greet
		&amp;#x20;         putStrLn $ \"Your additional arguments were: \" ++ show s
		&amp;#x20;         putStrLn $ \"Which is the same as: \" ++ show HFlags.arguments
		&amp;#x20; where
		&amp;#x20;   greet = putStrLn $ \"Hello \" ++ flags_name ++ \", very nice to meet you!\"
		@
		
		At @initHFlags@ time, the library also tries to gather flags out of
		environment variables.  @HFLAGS_verbose=True@ is equivalent to
		specify --verbose=True.  This environment feature only works with
		long options and the user has to specify a value even for Bools.
		
		/Since version 0.2, you mustn't put the initHFlags in a parentheses with the program description.  Just/ @$initHFlags@, /it's cleaner./
		
		See &lt;http://github.com/errge/hflags/tree/master/changelog&gt; for recent changes.
	</longdescription>
</pkgmetadata>

Lint Warnings

Manifest

Type File Size Versions
DIST hflags-0.4.3.tar.gz 17047 bytes 0.4.3
Unmatched Entries
Type File Size