]> git.saurik.com Git - apt.git/blob - cmdline/apt.cc
convert EDSP to be based on FileFd instead of FILE*
[apt.git] / cmdline / apt.cc
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
14 #include <apt-pkg/cmndline.h>
15 #include <apt-pkg/error.h>
16 #include <apt-pkg/init.h>
17 #include <apt-pkg/pkgsystem.h>
18 #include <apt-pkg/strutl.h>
19 #include <apt-pkg/configuration.h>
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>
31 #include <apt-private/private-sources.h>
32 #include <apt-private/private-source.h>
33 #include <apt-private/private-depends.h>
34 #include <apt-private/private-download.h>
35
36 #include <unistd.h>
37 #include <iostream>
38 #include <vector>
39
40 #include <apti18n.h>
41 /*}}}*/
42
43 static bool ShowHelp(CommandLine &) /*{{{*/
44 {
45 std::cout <<
46 _("Usage: apt [options] command\n"
47 "\n"
48 "apt is a commandline package manager and provides commands for\n"
49 "searching and managing as well as querying information about packages.\n"
50 "It provides the same functionality as the specialized APT tools,\n"
51 "like apt-get and apt-cache, but enables options more suitable for\n"
52 "interactive use by default.\n");
53 return true;
54 }
55 /*}}}*/
56 static std::vector<aptDispatchWithHelp> GetCommands() /*{{{*/
57 {
58 return {
59 // query
60 {"list", &DoList, _("list packages based on package names")},
61 {"search", &DoSearch, _("search in package descriptions")},
62 {"show", &ShowPackage, _("show package details")},
63
64 // package stuff
65 {"install", &DoInstall, _("install packages")},
66 {"remove", &DoInstall, _("remove packages")},
67 {"autoremove", &DoInstall, _("Remove automatically all unused packages")},
68 {"auto-remove", &DoInstall, nullptr},
69 {"purge", &DoInstall, nullptr},
70
71 // system wide stuff
72 {"update", &DoUpdate, _("update list of available packages")},
73 {"upgrade", &DoUpgrade, _("upgrade the system by installing/upgrading packages")},
74 {"full-upgrade", &DoDistUpgrade, _("upgrade the system by removing/installing/upgrading packages")},
75
76 // misc
77 {"edit-sources", &EditSources, _("edit the source information file")},
78 {"moo", &DoMoo, nullptr},
79
80 // for compat with muscle memory
81 {"dist-upgrade", &DoDistUpgrade, nullptr},
82 {"showsrc",&ShowSrcPackage, nullptr},
83 {"depends",&Depends, nullptr},
84 {"rdepends",&RDepends, nullptr},
85 {"policy",&Policy, nullptr},
86 {"build-dep", &DoBuildDep,nullptr},
87 {"clean", &DoClean, nullptr},
88 {"autoclean", &DoAutoClean, nullptr},
89 {"auto-clean", &DoAutoClean, nullptr},
90 {"source", &DoSource, nullptr},
91 {"download", &DoDownload, nullptr},
92 {"changelog", &DoChangelog, nullptr},
93
94 {nullptr, nullptr, nullptr}
95 };
96 }
97 /*}}}*/
98 int main(int argc, const char *argv[]) /*{{{*/
99 {
100 InitLocale();
101
102 CommandLine CmdL;
103 auto const Cmds = ParseCommandLine(CmdL, APT_CMD::APT, &_config, &_system, argc, argv, &ShowHelp, &GetCommands);
104
105 int const quiet = _config->FindI("quiet", 0);
106 if (quiet == 2)
107 {
108 _config->CndSet("quiet::NoProgress", true);
109 _config->Set("quiet", 1);
110 }
111
112 InitSignals();
113 InitOutput();
114
115 CheckIfCalledByScript(argc, argv);
116 CheckIfSimulateMode(CmdL);
117
118 return DispatchCommandLine(CmdL, Cmds);
119 }
120 /*}}}*/