@@ -62,15 +62,13 @@ int main(int argc, char *argv[]) {
6262 }
6363
6464 char * help_menu = "d: A dotfile manager.\n"
65- "Commands: <deploy | undeploy | print | compile>\n"
66- "Flags: --dry (for deploy/undeploy)" ;
65+ "Commands: <deploy[ --dry] | undeploy[ --dry] | print>\n" ;
6766
6867 enum Command {
6968 CommandNone ,
7069 CommandDeploy ,
7170 CommandUndeploy ,
7271 CommandPrint ,
73- CommandCompile ,
7472 } command = CommandNone ;
7573
7674 if (argc < 2 ) {
@@ -86,8 +84,6 @@ int main(int argc, char *argv[]) {
8684 command = CommandUndeploy ;
8785 } else if (strcmp (argv [1 ], "print" ) == 0 ) {
8886 command = CommandPrint ;
89- } else if (strcmp (argv [1 ], "compile" ) == 0 ) {
90- command = CommandCompile ;
9187 } else {
9288 char * strp = NULL ;
9389 if (asprintf (& strp , "\nSubcommand: %s\n---\nHELP MENU:\n%s" , argv [1 ], help_menu ) == -1 ) {
@@ -102,7 +98,6 @@ int main(int argc, char *argv[]) {
10298 .info = strp ,
10399 });
104100 }
105-
106101 if ((command == CommandDeploy || command == CommandUndeploy ) && argc > 2 ) {
107102 if (strcmp (argv [2 ], "--dry" ) == 0 ) {
108103 is_dry_run = true;
@@ -129,22 +124,17 @@ int main(int argc, char *argv[]) {
129124
130125 char * filename = basename (config_file_copy );
131126
132- if (command == CommandCompile ) {
133- if (asprintf (& cmd , "gcc -g -fPIC -c %s -o %s/%s.o && gcc -shared -o %s/libdotfiles.so %s/%s.o" ,
134- CONFIG_DIR , dir , filename , dir , dir , filename ) == -1 ) {
135- error ((struct Failure ){.operation = "format command with asprintf" , .reason = strerror (errno )});
136- goto error ;
137- }
138-
139- if (system (cmd ) == -1 ) {
140- error ((struct Failure ){.operation = "system" , .reason = strerror (errno )});
141- goto error ;
142- };
143-
144- printf ("Compiled configuration file\n" );
145- goto cleanup ;
127+ if (asprintf (& cmd , "gcc -g -fPIC -c %s -o %s/%s.o && gcc -shared -o %s/libdotfiles.so %s/%s.o" ,
128+ CONFIG_DIR , dir , filename , dir , dir , filename ) == -1 ) {
129+ error ((struct Failure ){.operation = "format command with asprintf" , .reason = strerror (errno )});
130+ goto error ;
146131 }
147132
133+ if (system (cmd ) == -1 ) {
134+ error ((struct Failure ){.operation = "system" , .reason = strerror (errno )});
135+ goto error ;
136+ };
137+
148138 handle = dlopen (lib_path , RTLD_LAZY );
149139 if (!handle ) {
150140 fprintf (stderr , "%s\n" , dlerror ());
@@ -222,14 +212,6 @@ int main(int argc, char *argv[]) {
222212 if (command == CommandPrint )
223213 printf ("]\n" );
224214
225- cleanup :
226- if (handle ) dlclose (handle );
227- if (lib_path ) free (lib_path );
228- if (config_file_copy ) free (config_file_copy );
229- if (config_dir ) free (config_dir );
230- if (cmd ) free (cmd );
231- return 1 ;
232-
233215error :
234216 if (handle ) dlclose (handle );
235217 if (lib_path ) free (lib_path );
0 commit comments