aboutsummaryrefslogtreecommitdiff
path: root/src/clients/paludis/command_line.cc
blob: 64905d6fa14b358ebea042f5e9a91ff6491e246b (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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
/* vim: set sw=4 sts=4 et foldmethod=syntax : */

/*
 * Copyright (c) 2006, 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
 *
 * This file is part of the Paludis package manager. Paludis is free software;
 * you can redistribute it and/or modify it under the terms of the GNU General
 * Public License version 2, as published by the Free Software Foundation.
 *
 * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 * details.
 *
 * You should have received a copy of the GNU General Public License along with
 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
 * Place, Suite 330, Boston, MA  02111-1307  USA
 */

#include "command_line.hh"
#include <paludis/util/instantiation_policy-impl.hh>

using namespace paludis;

template class paludis::InstantiationPolicy<CommandLine, paludis::instantiation_method::SingletonTag>;

CommandLine::CommandLine() :
    ArgsHandler(),

    action_args(this, "Actions",
            "Selects which basic action to perform. Exactly one action should "
            "be specified."),
    a_query(&action_args,     "query",        'q',  "Query for package information"),
    a_install(&action_args,   "install",      'i',  "Install one or more packages"),
    a_uninstall(&action_args, "uninstall",    'u',  "Uninstall one or more packages"),
    a_uninstall_unused(&action_args, "uninstall-unused",    '\0',  "Uninstall unused packages"),
    a_sync(&action_args,      "sync",         's',  "Sync all or specified repositories"),
    a_report(&action_args,    "report",       'r',  "Report the current state of the system"),
    a_contents(&action_args,  "contents",     'k',  "Display contents of a package"),
    a_owner(&action_args,     "owner",        'o',  "Display the owner of a file"),
    a_config(&action_args,    "config",       '\0',  "Run post-install configuration for a package"),
    a_version(&action_args,   "version",      'V',  "Display program version"),
    a_info(&action_args,      "info",         'I',  "Display program version and system information"),
    a_help(&action_args,      "help",         'h',  "Display program help"),

    action_args_internal(this, "More actions",
            "Additional actions, mostly for script and internal use."),
    a_has_version(&action_args_internal, "has-version", '\0', "Check whether the specified spec is installed"),
    a_best_version(&action_args_internal, "best-version", '\0', "Display the best version of the specified spec"),
    a_match(&action_args_internal, "match", '\0', "Display all installed packages matching the supplied argument"),
    a_environment_variable(&action_args_internal, "environment-variable", '\0', "Display the value of an environment "
            "variable for a particular package"),
    a_configuration_variable(&action_args_internal, "configuration-variable", '\0', "Display the value of a "
            "configuration variable for a particular repository"),
    a_list_repositories(&action_args_internal, "list-repositories", '\0', "List available repositories"),
    a_list_categories(&action_args_internal, "list-categories", '\0', "List available categories"),
    a_list_packages(&action_args_internal, "list-packages", '\0', "List available packages"),
    a_list_sets(&action_args_internal, "list-sets", '\0', "List available package sets"),
    a_list_sync_protocols(&action_args_internal, "list-sync-protocols", '\0', "List available sync protocols"),
    a_list_repository_formats(&action_args_internal, "list-repository-formats", '\0',
            "List available repository formats"),
    a_list_dep_tag_categories(&action_args_internal, "list-dep-tag-categories", '\0', "List known dep tag categories"),
    a_regenerate_installed_cache(&action_args_internal, "regenerate-installed-cache", '\0',
            "Regenerate (non-metadata) cache for installed repositories"),
    a_regenerate_installable_cache(&action_args_internal, "regenerate-installable-cache", '\0',
            "Regenerate (non-metadata) cache for installable repositories"),

    general_args(this, "General options",
            "Options which are relevant for most or all actions."),
    a_log_level(&general_args, "log-level",  '\0'),
    a_no_colour(&general_args, "no-colour", '\0', "Do not use colour"),
    a_no_color(&a_no_colour, "no-color"),
    a_environment(&general_args, "environment", 'E', "Environment specification (class:suffix, both parts optional)"),
    a_resume_command_template(&general_args, "resume-command-template", '\0', "Save the resume command to a file. If the filename contains 'XXXXXX', use mkstemp(3) to generate the filename"),

    query_args(this, "Query options",
            "Options which are relevant for --query."),
    a_show_deps(&query_args,        "show-deps",    'D', "Show dependencies"),
    a_show_metadata(&query_args,    "show-metadata", 'M', "Show raw metadata"),

    install_args(this, "Install, Uninstall options",
            "Options which are relevant for --install, --uninstall or --uninstall-unused."),
    a_pretend(&install_args, "pretend", 'p', "Pretend only"),
    a_destinations(&install_args, "destinations", 'd', "Use specified destinations instead of defaults"),
    a_preserve_world(&install_args, "preserve-world", '1', "Don't modify the world file"),
    a_add_to_world_spec(&install_args, "add-to-world-spec", '\0',
            "Use this spec, rather than all targets, for updating world (for resume commands)"),
    a_no_config_protection(&install_args, "no-config-protection", '\0', "Disable config file protection (dangerous)"),
    a_debug_build(&install_args, "debug-build", '\0'),
    a_checks(&install_args, "checks", '\0'),
    a_fetch(&install_args, "fetch", 'f', "Only fetch sources; don't install anything"),
    a_no_safe_resume(&install_args, "no-safe-resume", '\0', "Do not allow interrupted downloads to be resumed"),
    a_show_reasons(&install_args, "show-reasons", '\0', "Show why packages are being (un)installed",
            args::EnumArg::EnumArgOptions
            ("none",    "Don't show any information")
            ("summary", "Show a summary")
            ("full",    "Show full output (can be very verbose)"),
            "none"),
    a_show_use_descriptions(&install_args, "show-use-descriptions", '\0', "Show descriptions of USE flags",
            args::EnumArg::EnumArgOptions
            ("none",       "Don't show any descriptions")
            ("new",        "Show for new use flags")
            ("changed",    "Show for new and changed flags")
            ("all",        "Show for all flags"),
            "none"),
    a_continue_on_faillure(&install_args, "continue-on-failure", '\0', "Whether to continue after a fetch or install error",
            args::EnumArg::EnumArgOptions
            ("if-fetch-only",       "If fetching only")
            ("never",               "Never")
            ("if-satisfied",        "If remaining packages' dependencies are satisfied")
            ("always",              "Always (UNSAFE)"),
            "if-fetch-only"),

    uninstall_args(this, "Uninstall options",
            "Options which are relevant for --uninstall."),
    a_with_unused_dependencies(&uninstall_args, "with-unused-dependencies", '\0',
            "Also uninstall any dependencies of the target that are no longer used"),
    a_with_dependencies(&uninstall_args, "with-dependencies", '\0',
            "Also uninstall packages that depend upon the target"),
    a_all_versions(&uninstall_args, "all-versions", '\0',
            "Uninstall all versions of a package"),
    a_permit_unsafe_uninstalls(&uninstall_args, "permit-unsafe-uninstalls", '\0',
            "Allow depended-upon packages to uninstalled"),

    dl_args(this, "DepList behaviour",
            "Modify dependency list generation behaviour. Use with caution."),

    dl_reinstall(&dl_args, "dl-reinstall", '\0', "When to reinstall packages",
            args::EnumArg::EnumArgOptions
            ("never",          "Never")
            ("always",         "Always")
            ("if-use-changed", "If USE flags have changed"),
            "never"),
    dl_reinstall_scm(&dl_args, "dl-reinstall-scm", '\0', "When to reinstall scm packages",
            args::EnumArg::EnumArgOptions
            ("never",          "Never")
            ("always",         "Always")
            ("daily",          "If they are over a day old")
            ("weekly",         "If they are over a week old"),
            "never"),
    dl_reinstall_targets(&dl_args, "dl-reinstall-targets", '\0', "Whether to reinstall targets",
            args::EnumArg::EnumArgOptions
            ("auto",           "If the target is a set, never, otherwise always")
            ("never",          "Never")
            ("always",         "Always"),
            "auto"),

    dl_upgrade(&dl_args, "dl-upgrade", '\0', "When to upgrade packages",
            args::EnumArg::EnumArgOptions
            ("always",        "Always")
            ("as-needed",     "As needed"),
            "always"),
    dl_new_slots(&dl_args, "dl-new-slots", '\0', "When to pull in new slots (works with --dl-upgrade)",
            args::EnumArg::EnumArgOptions
            ("always",        "Always")
            ("as-needed",     "As needed"),
            "always"),
    dl_downgrade(&dl_args, "dl-downgrade", '\0', "When to downgrade packages",
            args::EnumArg::EnumArgOptions
            ("as-needed",     "As needed")
            ("warning",       "As needed, but warn when doing so")
            ("error",         "Downgrades should be treated as errors"),
            "as-needed"),

    dl_deps_default(&dl_args, "dl-deps-default", '\0',
            "Override default behaviour for all dependency classes",
            static_cast<DepListDepsOption>(-1)),

    dl_installed_deps_pre(&dl_args, "dl-installed-deps-pre", '\0',
            "How to handle pre dependencies for installed packages",
            dl_deps_discard),
    dl_installed_deps_runtime(&dl_args, "dl-installed-deps-runtime", '\0',
            "How to handle runtime dependencies for installed packages",
            dl_deps_try_post),
    dl_installed_deps_post(&dl_args, "dl-installed-deps-post", '\0',
            "How to handle post dependencies for installed packages",
            dl_deps_try_post),

    dl_uninstalled_deps_pre(&dl_args, "dl-uninstalled-deps-pre", '\0',
            "How to handle pre dependencies for uninstalled packages",
            dl_deps_pre),
    dl_uninstalled_deps_runtime(&dl_args, "dl-uninstalled-deps-runtime", '\0',
            "How to handle runtime dependencies for uninstalled packages",
            dl_deps_pre_or_post),
    dl_uninstalled_deps_post(&dl_args, "dl-uninstalled-deps-post", '\0',
            "How to handle post dependencies for uninstalled packages",
            dl_deps_post),
    dl_uninstalled_deps_suggested(&dl_args, "dl-uninstalled-deps-suggested", '\0',
            "How to handle suggested dependencies for uninstalled packages (only with --dl-suggested install)",
            dl_deps_post),

    dl_suggested(&dl_args, "dl-suggested", '\0', "How to handle suggested dependencies",
            args::EnumArg::EnumArgOptions
            ("show",         "Display, but do not install")
            ("install",      "Install")
            ("discard",      "Discard"),
            "show"),
    dl_circular(&dl_args, "dl-circular", '\0', "How to handle circular dependencies",
            args::EnumArg::EnumArgOptions
            ("error",         "Raise an error")
            ("discard",       "Discard"),
            "error"),
    dl_blocks(&dl_args, "dl-blocks", '\0', "How to handle blocks",
            args::EnumArg::EnumArgOptions
            ("accumulate",         "Accumulate and show in the dependency list")
            ("error",              "Error straight away")
            ("discard",            "Discard (dangerous)"),
            "error"),
    dl_override_masks(&dl_args, "dl-override-masks", '\0',
            "Zero or more mask kinds that can be overridden as necessary",
            args::StringSetArg::StringSetArgOptions
            ("tilde-keyword",           "Keyword masks where accepting ~ would work")
            ("unkeyworded",             "Keyword masks where a package is unkeyworded")
            ("repository",              "Repository masks")
            ("profile",                 "Deprecated synonym for repository")
            ("license",                 "License masks")),

    dl_fall_back(&dl_args, "dl-fall-back", '\0', "When to fall back to installed packages",
            args::EnumArg::EnumArgOptions
            ("as-needed-except-targets", "Where necessary, but not for target packages")
            ("as-needed",                "Where necessary, including for target packages")
            ("never",                    "Never"),
            "as-needed-except-targets"),

    list_args(this, "List options",
            "Options relevant for one or more of the --list actions."),
    a_repository(&list_args, "repository", '\0', "Matches with this repository name only",
            paludis::args::StringSetArg::StringSetArgOptions(), &paludis::RepositoryNameValidator::validate),
    a_repository_format(&list_args, "repository-format", '\0', "Matches with this repository format only"),
    a_category(&list_args,   "category",   '\0', "Matches with this category name only",
            paludis::args::StringSetArg::StringSetArgOptions(), &paludis::CategoryNamePartValidator::validate),
    a_package(&list_args,    "package",    '\0', "Matches with this package name only",
            paludis::args::StringSetArg::StringSetArgOptions(), &paludis::PackageNamePartValidator::validate),
    a_set(&list_args,        "set",        '\0', "Matches with this package set name only",
            paludis::args::StringSetArg::StringSetArgOptions(), &paludis::SetNameValidator::validate),

    owner_args(this, "Owner options",
            "Options relevant for the --owner actions."),
    a_full_match(&owner_args, "full-match", '\0', "Match whole filename"),

    deprecated_args(this, "Deprecated options", "Deprecated options."),
    a_dl_no_unnecessary_upgrades(&deprecated_args, "dl-no-unnecessary-upgrades", 'U',
            "Replaced by --dl-upgrade as-needed"),
    a_dl_drop_all(&deprecated_args, "dl-drop-all", '0',
            "Replaced by --dl-deps-default discard"),
    a_dl_ignore_installed(&deprecated_args, "dl-ignore-installed", 'e',
            "Replaced by --dl-reinstall always"),
    a_show_install_reasons(&deprecated_args, "show-install-reasons",
            '\0', "Replaced by --show-reasons"),
    a_add_to_world_atom(&deprecated_args, "add-to-world-atom", '\0',
            "Replaced by --add-to-world-spec"),
    a_config_suffix(&deprecated_args, "config-suffix", 'c',
            "Replaced by --environment"),
    a_update_news(&deprecated_args, "update-news", '\0',
            "No longer useful, does nothing"),
    a_safe_resume(&deprecated_args, "safe-resume", '\0',
            "Now default behaviour, use --no-safe-resume to disable")
{
    add_usage_line("--query [query options] target ...");
    add_usage_line("--install [install options] target ...");
    add_usage_line("--sync [target (leave blank for all)]");
    add_usage_line("--report");
    add_usage_line("--contents target ...");
    add_usage_line("--owner [owner options] files ...");
    add_usage_line("--version");
    add_usage_line("--info");
    add_usage_line("--help");

    add_usage_line("--has-version spec");
    add_usage_line("--best-version spec");
    add_usage_line("--environment-variable spec variable");
    add_usage_line("--configuration-variable repository variable");
    add_usage_line("--list-repositories [--repository repo1 --repository repo2 ...]");
    add_usage_line("--list-categories [--repository repo1 ... --category cat1 --category cat2 ...]");
    add_usage_line("--list-packages [--repository repo1 ... --category cat1 ... --package pkg1 --package pkg2 ...]");
    add_usage_line("--list-sets [--repository repo1 ... --set set1 ...]");
    add_usage_line("--list-sync-protocols");
    add_usage_line("--list-repository-formats");
    add_usage_line("--list-dep-tag-categories");

    add_environment_variable("PALUDIS_HOME", "Overrides the home directory used when searching "
            "for configuration files etc.");
    add_environment_variable("PALUDIS_NO_GLOBAL_HOOKS", "Don't use global hooks. Mostly for "
            "internal and test case use.");
    add_environment_variable("PALUDIS_SKIP_CONFIG", "Don't load configuration. Mostly for "
            "internal and test case use.");
    add_environment_variable("PALUDIS_EBUILD_DIR", "Where to look for ebuild.bash and related "
            "utilities.");
    add_environment_variable("PALUDIS_REPOSITORY_SO_DIR", "Where to look for repository .so "
            "files.");
    add_environment_variable("PALUDIS_FETCHERS_DIR", "Where to look for fetcher scripts.");
    add_environment_variable("PALUDIS_OPTIONS", "Default command-line options.");
}

std::string
CommandLine::app_name() const
{
    return "paludis";
}

std::string
CommandLine::app_synopsis() const
{
    return "The other package mangler";
}

std::string
CommandLine::app_description() const
{
    return
        "paludis is the command line interface used to handle packages. It can query and "
        "install packages, update repositories and display information about packages "
        "already installed on a system.";
}

CommandLine::~CommandLine()
{
}