Flox Package Database 1
CRUD Operations on Nix Package Metadata
Loading...
Searching...
No Matches
command.hh
Go to the documentation of this file.
1/* ========================================================================== *
2 *
3 * @file flox/pkgdb/command.hh
4 *
5 * @brief Executable command helpers, argument parsers, etc.
6 *
7 *
8 * -------------------------------------------------------------------------- */
9
10#pragma once
11
12#include "flox/core/command.hh"
13#include "flox/pkgdb/input.hh"
14#include "flox/pkgdb/write.hh"
15
16
17/* -------------------------------------------------------------------------- */
18
19namespace flox::pkgdb {
20
21/* -------------------------------------------------------------------------- */
22
25{
26
27 std::optional<std::filesystem::path> dbPath;
28
30 argparse::Argument &
31 addDatabasePathOption( argparse::ArgumentParser & parser );
32
33
34}; /* End struct `DbPathMixin' */
35
36
37/* -------------------------------------------------------------------------- */
38
43template<pkgdb_typename T>
45 : virtual public DbPathMixin
46 , virtual public command::InlineInputMixin
47{
48
49 std::shared_ptr<FloxFlake> flake;
50 std::shared_ptr<T> db;
51
56 void
58
63 argparse::Argument &
64 addTargetArg( argparse::ArgumentParser & parser );
65
66
67}; /* End struct `PkgDbMixin' */
68
69
70/* -------------------------------------------------------------------------- */
71
77 : public DbPathMixin
80{
81
82private:
83
85 std::optional<PkgDbInput> input;
87 bool force = false;
88
90 void
91 initInput();
92
93
94public:
95
97
98 [[nodiscard]] command::VerboseParser &
99 getParser()
100 {
101 return this->parser;
102 }
103
108 int
109 run();
110
111
112}; /* End class `ScrapeCommand' */
113
114
115/* -------------------------------------------------------------------------- */
116
134 : public PkgDbMixin<PkgDbReadOnly>
136{
137
138private:
139
147 bool isPkg = false;
148 row_id id = 0;
149
154 int
155 runId();
156
161 int
162 runDone();
163
168 int
169 runPath();
170
175 int
176 runFlake();
177
182 int
183 runDb();
184
189 int
190 runPkg();
191
192
193public:
194
195 GetCommand();
196
197 [[nodiscard]] command::VerboseParser &
198 getParser()
199 {
200 return this->parser;
201 }
202
207 int
208 run();
209
210
211}; /* End class `GetCommand' */
212
213
214/* -------------------------------------------------------------------------- */
215
217{
218
219private:
220
222 std::optional<std::filesystem::path> cacheDir;
223 bool json = false;
224 bool basenames = false;
225
226
227public:
228
229 ListCommand();
230
231 [[nodiscard]] command::VerboseParser &
232 getParser()
233 {
234 return this->parser;
235 }
236
241 int
242 run();
243
244
245}; /* End class `ListCommand' */
246
247
248/* -------------------------------------------------------------------------- */
249
250} // namespace flox::pkgdb
251
252
253/* -------------------------------------------------------------------------- *
254 *
255 *
256 *
257 * ========================================================================== */
Extend a command's state blob with a single RegistryInput.
Definition: command.hh:59
Minimal set of DB queries, largely focused on looking up info that is non-trivial to query with a "pl...
Definition: command.hh:136
command::VerboseParser pPath
Definition: command.hh:142
int runPath()
Execute the get path routine.
Definition: get.cc:120
int runId()
Execute the get id routine.
Definition: get.cc:88
int runDone()
Execute the get done routine.
Definition: get.cc:102
int run()
Execute the get routine.
Definition: get.cc:189
int runPkg()
Execute the get pkg routine.
Definition: get.cc:173
command::VerboseParser pFlake
Definition: command.hh:144
int runFlake()
Execute the get flake routine.
Definition: get.cc:139
command::VerboseParser pId
Definition: command.hh:141
command::VerboseParser pDone
Definition: command.hh:143
int runDb()
Execute the get db routine.
Definition: get.cc:154
command::VerboseParser parser
Definition: command.hh:140
command::VerboseParser pPkg
Definition: command.hh:146
command::VerboseParser pDb
Definition: command.hh:145
Definition: command.hh:217
int run()
Execute the list routine.
Definition: list.cc:48
Scrape a flake prefix producing a SQLite3 database with package metadata.
Definition: command.hh:80
bool force
Definition: command.hh:87
int run()
Execute the scrape routine.
Definition: scrape.cc:61
void initInput()
Initialize input from registryInput.
Definition: scrape.cc:39
Executable command helpers, argument parsers, etc.
A RegistryInput that opens a PkgDb associated with a flake.
Interfaces for caching package metadata in SQLite3 databases.
Definition: command.cc:44
uint64_t row_id
Definition: pkg-query.hh:48
Extend a command state blob with an attribute path to "target".
Definition: command.hh:103
Add verbosity flags to any parser and modify the global verbosity.
Definition: command.hh:49
Adds a single package database path to a state blob.
Definition: command.hh:25
argparse::Argument & addDatabasePathOption(argparse::ArgumentParser &parser)
Definition: command.cc:49
Adds a single package database and optionally an associated flake to a state blob.
Definition: command.hh:47
void openPkgDb()
Open a flox::pkgdb::PkgDb connection using the command state's dbPath or flake value.
argparse::Argument & addTargetArg(argparse::ArgumentParser &parser)
Add target argument to any parser to read either a flake-ref or path to an existing database.
Definition: command.cc:149
Interfaces for writing to a SQLite3 package set database.