Skip to content

Commit 1a5cc06

Browse files
committed
cufetchpm: args: add list --verbose
1 parent f249591 commit 1a5cc06

4 files changed

Lines changed: 43 additions & 26 deletions

File tree

cufetchpm/src/main.cpp

Lines changed: 33 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,12 @@ void version()
3636

3737
void help(int invalid_opt = false)
3838
{
39-
fmt::print(R"(Usage: cufetchpm <command> [options]
39+
fmt::print(R"(Usage: cufetchpm <COMMAND> [OPTIONS]...
4040
Manage plugins for customfetch.
4141
4242
Commands:
43-
install [options] <repo/path>... Install one or more plugin sources from a Git repo or local path.
44-
help <command> Show help for a specific command.
43+
install [OPTIONS] <repo/path>... Install one or more plugin sources from a Git repo or local path.
44+
help <COMMAND> Show help for a specific command.
4545
4646
Global options:
4747
-h, --help Show this help message.
@@ -217,11 +217,11 @@ int main(int argc, char* argv[])
217217
case INSTALL:
218218
{
219219
if (options.arguments.size() < 1)
220-
die("Please provide a singular git url repository");
220+
die("Please provide a git url repository");
221221
PluginManager plugin_manager(std::move(state));
222222
for (const std::string& arg : options.arguments)
223223
{
224-
if (arg.find("://") == arg.npos && fs::exists(arg))
224+
if (fs::exists(arg))
225225
plugin_manager.build_plugins(arg);
226226
else
227227
plugin_manager.add_repo_plugins(arg);
@@ -230,21 +230,37 @@ int main(int argc, char* argv[])
230230
}
231231
case LIST:
232232
{
233-
for (const manifest_t& manifest : state.get_all_repos())
233+
if (options.list_verbose)
234234
{
235-
fmt::println("\033[1;32mRepository:\033[0m {}", manifest.name);
236-
fmt::println("\033[1;33mURL:\033[0m {}", manifest.url);
237-
fmt::println("\033[1;34mPlugins:");
238-
for (const plugin_t& plugin : manifest.plugins)
235+
for (const manifest_t& manifest : state.get_all_repos())
239236
{
240-
fmt::println("\033[1;34m - {}\033[0m", plugin.name);
241-
fmt::println("\t\033[1;35mDescription:\033[0m {}", plugin.description);
242-
fmt::println("\t\033[1;36mAuthor(s):\033[0m {}", fmt::join(plugin.authors, ", "));
243-
fmt::println("\t\033[1;38;2;220;220;220mLicense(s):\033[0m {}", fmt::join(plugin.licenses, ", "));
244-
fmt::println("\t\033[1;38;2;144;238;144mPrefixe(s):\033[0m {}", fmt::join(plugin.prefixes, ", "));
245-
fmt::print("\n");
237+
fmt::println("\033[1;32mRepository:\033[0m {}", manifest.name);
238+
fmt::println("\033[1;33mURL:\033[0m {}", manifest.url);
239+
fmt::println("\033[1;34mPlugins:");
240+
for (const plugin_t& plugin : manifest.plugins)
241+
{
242+
fmt::println("\033[1;34m - {}\033[0m", plugin.name);
243+
fmt::println("\t\033[1;35mDescription:\033[0m {}", plugin.description);
244+
fmt::println("\t\033[1;36mAuthor(s):\033[0m {}", fmt::join(plugin.authors, ", "));
245+
fmt::println("\t\033[1;38;2;220;220;220mLicense(s):\033[0m {}",
246+
fmt::join(plugin.licenses, ", "));
247+
fmt::println("\t\033[1;38;2;144;238;144mPrefixe(s):\033[0m {}",
248+
fmt::join(plugin.prefixes, ", "));
249+
fmt::print("\n");
250+
}
251+
fmt::print("\033[0m");
252+
}
253+
}
254+
else
255+
{
256+
for (const manifest_t& manifest : state.get_all_repos())
257+
{
258+
fmt::println("\033[1;32mRepository:\033[0m {} (\033[1;33m{}\033[0m)", manifest.name, manifest.url);
259+
fmt::println("\033[1;34mPlugins:");
260+
for (const plugin_t& plugin : manifest.plugins)
261+
fmt::println(" \033[1;34m{} - \033[1;35m{}\n", plugin.name, plugin.description);
262+
fmt::print("\033[0m");
246263
}
247-
fmt::print("\033[0m");
248264
}
249265
break;
250266
}

cufetchpm/src/manifest.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ std::vector<std::string> ManifestSpace::getStrArrayValue(const toml::table& tbl,
4242
return {};
4343
}
4444

45-
std::vector<std::string> ManifestSpace::getStrArrayValue(const toml::table& tbl, const std::string_view name, const std::string_view value)
45+
std::vector<std::string> ManifestSpace::getStrArrayValue(const toml::table& tbl, const std::string_view name,
46+
const std::string_view value)
4647
{
4748
std::vector<std::string> ret;
4849

cufetchpm/src/pluginManager.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,13 +96,13 @@ void PluginManager::build_plugins(const fs::path& working_dir)
9696
m_state.add_new_repo(manifest);
9797

9898
// we built all plugins. let's rename the working directory to its actual manifest name,
99-
success("Repository plugins successfully built! Moving to '{}'...", repo_cache_path.string());
99+
success("Repository plugins successfully built! Renaming to '{}'...", repo_cache_path.string());
100100
fs::create_directories(repo_cache_path);
101101
fs::rename(working_dir, repo_cache_path);
102102

103-
// and then we symlink each plugin built library from its output-dir
103+
// and then we move each plugin built library from its output-dir
104104
fs::create_directories(plugin_config_path);
105-
status("Linking each built plugin to '{}'", plugin_config_path.string());
105+
status("Moving each built plugin to '{}'", plugin_config_path.string());
106106
for (const plugin_t& plugin : manifest.get_all_plugins())
107107
{
108108
if (!fs::exists(plugin.output_dir))
@@ -119,7 +119,7 @@ void PluginManager::build_plugins(const fs::path& working_dir)
119119
}
120120

121121
if (library.is_regular_file() || library.is_symlink())
122-
fs::create_symlink(fs::canonical(library), library_config_path);
122+
fs::rename(fs::canonical(library), library_config_path);
123123
else
124124
error("Built library '{}' is not a regular file", library.path().string());
125125
}

cufetchpm/src/stateManager.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,11 +153,11 @@ std::vector<manifest_t> StateManager::get_all_repos()
153153
continue;
154154

155155
plugin_t plugin;
156-
plugin.name = getStrValue(*plugin_tbl, "name");
156+
plugin.name = getStrValue(*plugin_tbl, "name");
157157
plugin.description = getStrValue(*plugin_tbl, "description");
158-
plugin.output_dir = getStrValue(*plugin_tbl, "output-dir");
159-
plugin.authors = getStrArrayValue(*plugin_tbl, "authors");
160-
plugin.licenses = getStrArrayValue(*plugin_tbl, "licenses");
158+
plugin.output_dir = getStrValue(*plugin_tbl, "output-dir");
159+
plugin.authors = getStrArrayValue(*plugin_tbl, "authors");
160+
plugin.licenses = getStrArrayValue(*plugin_tbl, "licenses");
161161

162162
manifest.plugins.push_back(std::move(plugin));
163163
}

0 commit comments

Comments
 (0)