]> git.saurik.com Git - apt.git/blame - cmdline/apt.cc
new quiet level -qq for apt to hide progress output
[apt.git] / cmdline / apt.cc
CommitLineData
b9179170
MV
1// -*- mode: cpp; mode: fold -*-
2// Description /*{{{*/
3/* ######################################################################
4
5 apt - CLI UI for apt
6
7 Returns 100 on failure, 0 on success.
8
9 ##################################################################### */
10 /*}}}*/
11// Include Files /*{{{*/
12#include<config.h>
13
453b82a3 14#include <apt-pkg/cmndline.h>
b9179170 15#include <apt-pkg/error.h>
b9179170 16#include <apt-pkg/init.h>
b9179170 17#include <apt-pkg/pkgsystem.h>
453b82a3
DK
18#include <apt-pkg/strutl.h>
19#include <apt-pkg/configuration.h>
b9179170
MV
20
21#include <apt-private/private-list.h>
22#include <apt-private/private-search.h>
23#include <apt-private/private-install.h>
24#include <apt-private/private-output.h>
25#include <apt-private/private-update.h>
26#include <apt-private/private-cmndline.h>
27#include <apt-private/private-moo.h>
28#include <apt-private/private-upgrade.h>
29#include <apt-private/private-show.h>
30#include <apt-private/private-main.h>
9e6b13f3 31#include <apt-private/private-sources.h>
b9179170 32
453b82a3
DK
33#include <unistd.h>
34#include <iostream>
35#include <vector>
cfacba52 36
453b82a3
DK
37#include <apti18n.h>
38 /*}}}*/
cfacba52 39
cbbee23e 40static bool ShowHelp(CommandLine &, CommandLine::DispatchWithHelp const * Cmds)
b9179170 41{
2b0660b5 42 ioprintf(std::cout, "%s %s (%s)\n", PACKAGE, PACKAGE_VERSION, COMMON_ARCH);
b9179170
MV
43
44 // FIXME: generate from CommandLine
2b0660b5 45 std::cout <<
b9179170
MV
46 _("Usage: apt [options] command\n"
47 "\n"
cbbee23e
DK
48 "CLI for apt.\n")
49 << std::endl
50 << _("Commands:") << std::endl;
51 for (; Cmds->Handler != nullptr; ++Cmds)
52 {
53 if (Cmds->Help == nullptr)
54 continue;
55 std::cout << " " << Cmds->Match << " - " << Cmds->Help << std::endl;
56 }
57
b9179170
MV
58 return true;
59}
60
61int main(int argc, const char *argv[]) /*{{{*/
62{
e7e10e47
DK
63 InitLocale();
64
cbbee23e
DK
65 CommandLine::DispatchWithHelp Cmds[] = {
66 // query
67 {"list", &DoList, _("list packages based on package names")},
68 {"search", &DoSearch, _("search in package descriptions")},
69 {"show", &ShowPackage, _("show package details")},
70
71 // package stuff
72 {"install", &DoInstall, _("install packages")},
73 {"remove", &DoInstall, _("remove packages")},
74 {"autoremove", &DoInstall, _("Remove automatically all unused packages")},
75 {"auto-remove", &DoInstall, nullptr},
76 {"purge", &DoInstall, nullptr},
77
78 // system wide stuff
79 {"update", &DoUpdate, _("update list of available packages")},
80 {"upgrade", &DoUpgrade, _("upgrade the system by installing/upgrading packages")},
81 {"full-upgrade", &DoDistUpgrade, _("upgrade the system by removing/installing/upgrading packages")},
82 {"dist-upgrade", &DoDistUpgrade, nullptr}, // for compat with muscle memory
83
84 // misc
85 {"edit-sources", &EditSources, _("edit the source information file")},
86 {"moo", &DoMoo, nullptr},
87 {nullptr, nullptr, nullptr}
88 };
b9179170 89
ad7e0941 90 CommandLine CmdL;
e7e10e47 91 ParseCommandLine(CmdL, Cmds, "apt", &_config, &_system, argc, argv, ShowHelp);
b9179170 92
2b0660b5
DK
93 int const quiet = _config->FindI("quiet", 0);
94 if (quiet == 2)
95 {
96 _config->CndSet("quiet::NoProgress", true);
97 _config->Set("quiet", 1);
98 }
99
100 InitSignals();
101 InitOutput();
102
e7e10e47
DK
103 CheckIfCalledByScript(argc, argv);
104 CheckIfSimulateMode(CmdL);
b9179170 105
e7e10e47 106 return DispatchCommandLine(CmdL, Cmds);
b9179170
MV
107}
108 /*}}}*/