added more some comments

This commit is contained in:
phixxy 2026-03-21 15:08:29 -07:00
parent 7de932eeaa
commit 47b43dade6

View file

@ -127,27 +127,29 @@ int main(int argc, char *argv[])
int opt; int opt;
struct Flags f = {.use_v = 0, .filename="skratch-XXXXXX"}; struct Flags f = {.use_v = 0, .filename="skratch-XXXXXX"};
make_skratch_path(&f); make_skratch_path(&f);
//handle args
while ((opt = getopt(argc, argv, "cls:v")) != -1) while ((opt = getopt(argc, argv, "cls:v")) != -1)
{ {
switch (opt) switch (opt)
{ {
case 'c': case 'c': // delete ~/.skratch files
delete_files(&f); delete_files(&f);
return 0; return 0;
case 'l': case 'l': // list ~/.skratch files
list_files(&f, 0); list_files(&f, 0);
return 0; return 0;
case 's': case 's': // use file suffix, like .txt
f.use_s = 1; f.use_s = 1;
f.suffix = optarg; f.suffix = optarg;
break; break;
case 'v': case 'v': // use visual editor
f.use_v = 1; f.use_v = 1;
break; break;
default: default:
printf("error print usage"); printf("error print usage");
} }
} }
// find optional filename if exists
for (int i = optind; i < argc; i++) for (int i = optind; i < argc; i++)
{ {
if (!strcmp(f.filename,"skratch-XXXXXX")) if (!strcmp(f.filename,"skratch-XXXXXX"))