Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions apps/ll-cli/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,40 @@ ll-cli list --upgradable
"application(s), base(s) or runtime(s)"));
}

// Function to add the analyze size subcommand
void addAnalyzeSizeCommand(CLI::App &cliAnalyze, SizeOptions &sizeOptions)
{
auto *cliSize =
cliAnalyze.add_subcommand("size", _("Show installed module sizes and repository real size"))
->fallthrough();
cliSize->usage(_(R"(Usage: ll-cli analyze size [OPTIONS]

Example:
# show installed module sizes
ll-cli analyze size
)"));
cliSize
->add_option(
"--sort",
sizeOptions.sortBy,
_(R"(Sort result by specify field. One of "actual", "logical", "exclusive", "shared" or "id")"))
->type_name("FIELD")
->capture_default_str()
->check(CLI::IsMember({ "actual", "logical", "exclusive", "shared", "id" }));
cliSize->add_flag("--asc", sizeOptions.ascending, _("Sort in ascending order"));
}

// Function to add the analyze subcommands
void addAnalyzeCommand(CLI::App &commandParser, SizeOptions &sizeOptions, const std::string &group)
{
auto *cliAnalyze = commandParser.add_subcommand("analyze", _("Analyze installed applications"))
->group(group)
->usage(_("Usage: ll-cli analyze SUBCOMMAND [OPTIONS]"));
cliAnalyze->require_subcommand(1);

addAnalyzeSizeCommand(*cliAnalyze, sizeOptions);
}

// Function to add the info subcommand
void addInfoCommand(CLI::App &commandParser, InfoOptions &infoOptions, const std::string &group)
{
Expand Down Expand Up @@ -566,6 +600,7 @@ You can report bugs to the linyaps team under this project: https://github.com/O
SearchOptions searchOptions{};
UninstallOptions uninstallOptions{};
ListOptions listOptions{};
SizeOptions sizeOptions{};
InfoOptions infoOptions{};
ContentOptions contentOptions{};
linglong::common::cli::RepoOptions repoOptions{};
Expand All @@ -587,6 +622,7 @@ You can report bugs to the linyaps team under this project: https://github.com/O
addUpgradeCommand(commandParser, upgradeOptions, CliBuildInGroup);
addSearchCommand(commandParser, searchOptions, CliSearchGroup);
addListCommand(commandParser, listOptions, CliBuildInGroup);
addAnalyzeCommand(commandParser, sizeOptions, CliBuildInGroup);
linglong::common::cli::addRepoCommand(commandParser,
repoOptions,
CliRepoGroup,
Expand Down Expand Up @@ -743,6 +779,14 @@ You can report bugs to the linyaps team under this project: https://github.com/O
result = cli->uninstall(uninstallOptions);
} else if (name == "list") {
result = cli->list(listOptions);
} else if (name == "analyze") {
const auto &subcommands = (*ret)->get_subcommands();
auto subcommand = std::find_if(subcommands.begin(), subcommands.end(), [](CLI::App *app) {
return app->parsed();
});
if (subcommand != subcommands.end() && (*subcommand)->get_name() == "size") {
result = cli->size(sizeOptions);
}
} else if (name == "info") {
result = cli->info(infoOptions);
} else if (name == "content") {
Expand Down
Loading
Loading