diff options
author | Daniel Hartwig <mandyke@gmail.com> | 2012-06-08 01:22:03 +0800 |
---|---|---|
committer | Daniel Hartwig <mandyke@gmail.com> | 2012-06-16 13:48:54 +0800 |
commit | d082e98fcf8d2809fd89d3bc2c3002f5e2e1f5a3 (patch) | |
tree | e2f728603afb6bc787e31c92b68d4cd3c5b63cef /src/cmdline/cmdline_util.cc | |
parent | 6143ba98cf6c98a492e0fe9b247d42a2f95e4167 (diff) | |
download | aptitude-d082e98fcf8d2809fd89d3bc2c3002f5e2e1f5a3.tar.gz |
Use apt's CommandLine parser
Previously aptitude was using it's own command line
parser implemented on top of getopt. Replacing this
with the standard apt class means there are no longer
subtle quirks with our parser (such as "-qq" not
being valid, when it is fine for other apt programs).
The parser is closely tied to the Configuration, and
reads options directly in to the global apt config.
Some options were tracked independently of the global
config; this change is the first part rectifying that
situation. The goal is to keep all program options,
configuration state, etc. in the global config rather
than passing state variables between functions. Many
options which previously did not have an associated
configuration item now do; some remain undocumented
for now as they are transitional.
* handle "-qq" like other apt-utils
* properly process all -o command line options (Closes: #587671)
* unknown command line options trigger an error (Closes: #434502)
* --add-user-tag-to, --remove-user-tag-from are working;
no bug reports suggests that noone has noticed they
were broken
New aliases for some command-line options:
--yes, for --assume-yes (apt-get)
--default-release, for --target-release (apt-utils)
--install-on-startup, for -i
--update-on-startup, for -u
New configuration item:
Aptitude::CmdLine::Sorting, equivalent to --sort
Other new configuration items are for internal use only
at this point.
Closes: #587671
Closes: #434502
Diffstat (limited to 'src/cmdline/cmdline_util.cc')
-rw-r--r-- | src/cmdline/cmdline_util.cc | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/src/cmdline/cmdline_util.cc b/src/cmdline/cmdline_util.cc index bb0eb2fb..d7b1dcb4 100644 --- a/src/cmdline/cmdline_util.cc +++ b/src/cmdline/cmdline_util.cc @@ -732,6 +732,49 @@ namespace aptitude return rval; } + + bool read_user_tag_applications(std::vector<tag_application> &user_tags, + const char *config_item, + const bool is_add, const bool implicit) + { + const Configuration::Item *tree = aptcfg->Tree(config_item); + if(tree == NULL) + return true; + + for(Configuration::Item *item = tree->Child; + item != NULL; + item = item->Next) + { + if(implicit) + user_tags.push_back(tag_application(is_add, item->Value, NULL)); + else + { + const std::string arg(item->Value); + const std::string::size_type splitloc = arg.find(','); + if(splitloc == arg.npos) + return _error->Error(_("No comma following tag name \"%s\""), + arg.c_str()); + else + { + const std::string patternstr(arg, splitloc + 1); + const std::vector<const char *> terminators; + cwidget::util::ref_ptr<aptitude::matching::pattern> p = + aptitude::matching::parse(patternstr, + terminators, + true, + false); + if(p.valid() == false) + return false; + + const std::string tag(arg, 0, splitloc); + user_tags.push_back(tag_application(is_add, tag, p)); + } + } + } + + return true; + } + void apply_user_tags(const std::vector<tag_application> &user_tags) { using namespace matching; |