11#include < cstring>
2+
23#include " libcufetch/common.hh"
3- #include " libs/switch_fnv1a.hpp"
44#include " pluginManager.hpp"
55#include " stateManager.hpp"
66
1212
1313#include " getopt_port/getopt.h"
1414
15- enum {
15+ static int op = 0 ;
16+ enum
17+ {
1618 INSTALL,
1719 REMOVE,
1820 LIST
1921};
2022
21- static struct operations_t
23+ static struct operations_install_t
2224{
23- int name;
2425 std::vector<std::string> args;
25- } op ;
26+ } install_op ;
2627
2728static void version ()
2829{
@@ -44,7 +45,7 @@ Manage plugins for customfetch.
4445NOTE: the operations must be the first argument to pass
4546
4647OPERATIONS:
47- install - Install a new plugin repository. Takes as an argument the git url to be cloned.
48+ install - Install a new plugin repository. Takes as an argument the git url to be cloned.
4849
4950GENERAL OPTIONS
5051 -h, --help Print this help menu.
@@ -76,19 +77,19 @@ static bool parseargs(int argc, char* argv[])
7677 {
7778 if (strncmp (argv[i], " install" , 7 ) == 0 || strncmp (argv[i], " i" , 1 ) == 0 )
7879 {
79- op. name = INSTALL;
80+ op = INSTALL;
8081 optind++;
8182 break ;
8283 }
83- if (strncmp (argv[i], " list" , 4 ) == 0 || strncmp (argv[i], " l" , 1 ) == 0 )
84+ if (strncmp (argv[i], " list" , 4 ) == 0 || strncmp (argv[i], " l" , 1 ) == 0 )
8485 {
85- op. name = LIST;
86+ op = LIST;
8687 optind++;
8788 break ;
8889 }
8990 if (strncmp (argv[i], " remove" , 6 ) == 0 || strncmp (argv[i], " r" , 1 ) == 0 )
9091 {
91- op. name = REMOVE;
92+ op = REMOVE;
9293 optind++;
9394 break ;
9495 }
@@ -107,8 +108,12 @@ static bool parseargs(int argc, char* argv[])
107108 }
108109 }
109110
110- for (int i = optind; i < argc; ++i)
111- op.args .push_back (argv[i]);
111+ switch (op)
112+ {
113+ case INSTALL:
114+ for (int i = optind; i < argc; ++i)
115+ install_op.args .push_back (argv[i]);
116+ }
112117
113118 return true ;
114119}
@@ -119,18 +124,18 @@ int main(int argc, char* argv[])
119124 return -1 ;
120125
121126 fs::create_directories ({ getHomeCacheDir () / " cufetchpm" / " plugins" });
122- StateManager state;
123- PluginManager plugin_manager (std::move (state));
124- switch (op.name )
127+ switch (op)
125128 {
126- case INSTALL:
127- {
128- if (op.args .size () != 1 )
129- die (" Please provide a singular git url repository" );
130- plugin_manager.add_repo_plugins (op.args [0 ]); break ;
131- }
132- default :
133- warn (" Not yet implemented" );
129+ case INSTALL:
130+ {
131+ if (install_op.args .size () != 1 )
132+ die (" Please provide a singular git url repository" );
133+ StateManager state;
134+ PluginManager plugin_manager (std::move (state));
135+ plugin_manager.add_repo_plugins (install_op.args [0 ]);
136+ break ;
137+ }
138+ default : warn (" Not yet implemented" );
134139 }
135140
136141 return 0 ;
0 commit comments