Author:halw

Date:2010-04-19T19:29:56.000000Z


git-svn-id: https://svn.eiffel.com/eiffel-org/trunk@562 abb3cda0-5349-4a8f-a601-0c33ac3a8c38
This commit is contained in:
halw
2010-04-20 16:24:35 +00:00
parent afc12a52dd
commit ec64500dca
2 changed files with 309 additions and 0 deletions

View File

@@ -0,0 +1,51 @@
[[Property:title|Command line arguments]]
[[Property:link_title|Example: Command line arguments]]
[[Property:weight|0]]
[[Property:uuid|ba852d83-3c02-4d38-088a-60b76fe5c63f]]
==Description==
Retrieve the list of command-line arguments given to the program.
Example command line:
<code lang="text">
myprogram -c "alpha beta" -h "gamma"
</code>
==Notes==
This class inherits functionality for dealing with command line arguments from class <code lang="eiffel">ARGUMENTS</code>. It uses the feature <code lang="eiffel">separate_character_option_value</code> to return the values by option name for each of the two arguments. <code lang="eiffel">ARGUMENTS</code> provides a rich set of features for command line argument processing.
==Source==
Problem description from [http://rosettacode.org/wiki/Command-line_arguments Rosetta Code]
==Solution==
<code>
class
APPLICATION
inherit
ARGUMENTS
create
make
feature {NONE} -- Initialization
make
-- Print values for arguments with options 'c' and 'h'.
do
print ("Command line argument value for option 'c' is: ")
print (separate_character_option_value ('c') + "%N")
print ("Command line argument value for option 'h' is: ")
print (separate_character_option_value ('h') + "%N")
io.read_line -- Keep console window open
end
end
</code>
==Output (for command line arguments: -c "alpha beta" -h "gamma")==
<code lang="text">
Command line argument value for option 'c' is: alpha beta
Command line argument value for option 'h' is: gamma
</code>