Skip to content

Commit b800ecf

Browse files
committed
main.c :add clean command
1 parent d5266e8 commit b800ecf

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

main.c

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,28 @@ int main()
223223
fwprintf(stderr,L"ERROR:Invalid Arguments\n");
224224
return 1;
225225
}
226+
else if(wcscmp(wargv[1],L"clean") == 0)
227+
{
228+
char yn;
229+
wprintf(L"This will remove this distro (%s) from the filesystem.\n",TargetName);
230+
wprintf(L"Are you sure you would like to proceed? (This cannot be undone)\n");
231+
wprintf(L"Type \"y\" to continue:");
232+
scanf("%c",&yn);
233+
if(yn == 'y')
234+
{
235+
wprintf(L"Unregistering...\n");
236+
res = WslUnregisterDistribution(TargetName);
237+
if(res != 0)
238+
{
239+
fwprintf(stderr,L"ERROR:Unregister Failed!\nHRESULT:0x%x\n",res);
240+
return res;
241+
}
242+
wprintf(L"Successfully removed distro.");
243+
return 0;
244+
}
245+
fwprintf(stderr,L"Accepting is required to proceed. Exiting...");
246+
return 1;
247+
}
226248
else if(wcscmp(wargv[1],L"help") == 0)
227249
{
228250
show_usage();
@@ -233,7 +255,6 @@ int main()
233255
fwprintf(stderr,L"ERROR:Invalid Arguments.\n");
234256
wprintf(L"\n");
235257
show_usage();
236-
237258
return 1;
238259
}
239260
}
@@ -312,6 +333,8 @@ void show_usage()
312333
wprintf(L" - `--append-path`: Get on/off status of Append Windows PATH to $PATH\n");
313334
wprintf(L" - `--mount-drive`: Get on/off status of Mount drives\n");
314335
wprintf(L" - `--lxuid`: Get LxUID key for this distro\n\n");
336+
wprintf(L" clean\n");
337+
wprintf(L" - Uninstalls the distro.\n\n");
315338
wprintf(L" help\n");
316339
wprintf(L" - Print this usage message.\n\n");
317340

0 commit comments

Comments
 (0)