1AppConfig::Args(3)    User Contributed Perl Documentation   AppConfig::Args(3)
2
3
4

NAME

6       AppConfig::Args - Perl5 module for reading command line arguments.
7

SYNOPSIS

9           use AppConfig::Args;
10
11           my $state   = AppConfig::State->new(\%cfg);
12           my $cfgargs = AppConfig::Args->new($state);
13
14           $cfgargs->parse(\@args);            # read args
15

OVERVIEW

17       AppConfig::Args is a Perl5 module which reads command line arguments
18       and uses the options therein to update variable values in an
19       AppConfig::State object.
20
21       AppConfig::File is distributed as part of the AppConfig bundle.
22

DESCRIPTION

24   USING THE AppConfig::Args MODULE
25       To import and use the AppConfig::Args module the following line should
26       appear in your Perl script:
27
28           use AppConfig::Args;
29
30       AppConfig::Args is used automatically if you use the AppConfig module
31       and create an AppConfig::Args object through the parse() method.
32
33       AppConfig::File is implemented using object-oriented methods.  A new
34       AppConfig::Args object is created and initialised using the new()
35       method.  This returns a reference to a new AppConfig::File object.  A
36       reference to an AppConfig::State object should be passed in as the
37       first parameter:
38
39           my $state   = AppConfig::State->new();
40           my $cfgargs = AppConfig::Args->new($state);
41
42       This will create and return a reference to a new AppConfig::Args
43       object.
44
45   PARSING COMMAND LINE ARGUMENTS
46       The parse() method is used to read a list of command line arguments and
47       update the STATE accordingly.  A reference to the list of arguments
48       should be passed in.
49
50           $cfgargs->parse(\@ARGV);
51
52       If the method is called without a reference to an argument list then it
53       will examine and manipulate @ARGV.
54
55       If the PEDANTIC option is turned off in the AppConfig::State object,
56       any parsing errors (invalid variables, unvalidated values, etc) will
57       generate warnings, but not cause the method to return.  Having
58       processed all arguments, the method will return 1 if processed without
59       warning or 0 if one or more warnings were raised.  When the PEDANTIC
60       option is turned on, the method generates a warning and immediately
61       returns a value of 0 as soon as it encounters any parsing error.
62
63       The method continues parsing arguments until it detects the first one
64       that does not start with a leading dash, '-'.  Arguments that
65       constitute values for other options are not examined in this way.
66

FUTURE DEVELOPMENT

68       This module was developed to provide backwards compatibility (to some
69       degree) with the preceeding App::Config module.  The argument parsing
70       it provides is basic but offers a quick and efficient solution for
71       those times when simple option handling is all that is required.
72
73       If you require more flexibility in parsing command line arguments, then
74       you should consider using the AppConfig::Getopt module.  This is loaded
75       and used automatically by calling the AppConfig getopt() method.
76
77       The AppConfig::Getopt module provides considerably extended
78       functionality over the AppConfig::Args module by delegating out the
79       task of argument parsing to Johan Vromans' Getopt::Long module.  For
80       advanced command-line parsing, this module (either Getopt::Long by
81       itself, or in conjunction with AppConfig::Getopt) is highly
82       recommended.
83

AUTHOR

85       Andy Wardley, <abw@wardley.org>
86
88       Copyright (C) 1997-2007 Andy Wardley.  All Rights Reserved.
89
90       Copyright (C) 1997,1998 Canon Research Centre Europe Ltd.
91
92       This module is free software; you can redistribute it and/or modify it
93       under the same terms as Perl itself.
94

SEE ALSO

96       AppConfig, AppConfig::State, AppConfig::Getopt, Getopt::Long
97
98
99
100perl v5.38.0                      2023-07-20                AppConfig::Args(3)
Impressum