Update main.c
This commit is contained in:
30
src/main.c
30
src/main.c
@@ -24,13 +24,14 @@
|
|||||||
#include "../config.h"
|
#include "../config.h"
|
||||||
#include "name.h"
|
#include "name.h"
|
||||||
|
|
||||||
static struct option longopts[] = { { "author", required_argument, 0, 'a' },
|
static const struct option longopts[] = {
|
||||||
|
{ "author", required_argument, 0, 'a' },
|
||||||
{ "licence", required_argument, 0, 'l' },
|
{ "licence", required_argument, 0, 'l' },
|
||||||
{ 0, 0, 0, 0 } };
|
{ 0, 0, 0, 0 } };
|
||||||
|
|
||||||
static int exit_status;
|
static int exit_status;
|
||||||
|
|
||||||
static void usage(int status);
|
static void print_help();
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
@@ -47,14 +48,14 @@ int main(int argc, char **argv)
|
|||||||
.project = "Project",
|
.project = "Project",
|
||||||
};
|
};
|
||||||
|
|
||||||
parse_standard_options(argc, argv, usage, emit_version);
|
parse_standard_options(argc, argv, print_help, emit_version);
|
||||||
|
|
||||||
while ((optc = getopt_long(argc, argv, "a:l:E", longopts, NULL)) != -1)
|
while ((optc = getopt_long(argc, argv, "a:l:E", longopts, NULL)) != -1)
|
||||||
|
|
||||||
switch (optc) {
|
switch (optc) {
|
||||||
case 'l':
|
case 'l':
|
||||||
if (!strcmp(optarg, "list")) {
|
if (!strcmp(optarg, "list")) {
|
||||||
printf("BSD\nGPL\nMIT\n");
|
puts("BSD\nGPL\nMIT");
|
||||||
exit(EXIT_SUCCESS);
|
exit(EXIT_SUCCESS);
|
||||||
}
|
}
|
||||||
if (!strcmp(optarg, "GPL"))
|
if (!strcmp(optarg, "GPL"))
|
||||||
@@ -62,7 +63,7 @@ int main(int argc, char **argv)
|
|||||||
else if (!strcmp(optarg, "MIT"))
|
else if (!strcmp(optarg, "MIT"))
|
||||||
manifest.licence = MIT;
|
manifest.licence = MIT;
|
||||||
else {
|
else {
|
||||||
printf("BSD\nGPL\nMIT\n");
|
puts("BSD\nGPL\nMIT");
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -72,6 +73,10 @@ int main(int argc, char **argv)
|
|||||||
default:
|
default:
|
||||||
lose = 1;
|
lose = 1;
|
||||||
}
|
}
|
||||||
|
if (lose || optind < argc) {
|
||||||
|
errorf("extra operand: %s", argv[optind]);
|
||||||
|
usage();
|
||||||
|
}
|
||||||
|
|
||||||
char *cwd = getcwd(NULL, 0);
|
char *cwd = getcwd(NULL, 0);
|
||||||
if (!cwd) {
|
if (!cwd) {
|
||||||
@@ -83,14 +88,9 @@ int main(int argc, char **argv)
|
|||||||
return exit_status;
|
return exit_status;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void usage(int status)
|
static void print_help()
|
||||||
{
|
{
|
||||||
if (status != 0) {
|
printf("Usage: %s [OPTION]... [project-name]...\n", PROGRAM);
|
||||||
puts("Try 'yait --help' for more information.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
printf("Usage: %s [OPTION]... [project-name]\n", PROGRAM);
|
|
||||||
fputs("\
|
fputs("\
|
||||||
Generates an optionated C project.\n",
|
Generates an optionated C project.\n",
|
||||||
stdout);
|
stdout);
|
||||||
@@ -101,8 +101,10 @@ Generates an optionated C project.\n",
|
|||||||
stdout);
|
stdout);
|
||||||
puts("");
|
puts("");
|
||||||
fputs("\
|
fputs("\
|
||||||
-E Open $EDITOR after project creation (default false)\n\
|
-E Open $EDITOR after project creation\n\
|
||||||
--author=NAME Set the program author (default git username)\n\
|
-q, --quiet Only print required messages\n\
|
||||||
|
-f, --force Overwrite existing files\n\
|
||||||
|
--author=NAME Set the program author (default git username|system username)\n\
|
||||||
--licence=LICENCE Set the program licence (default BSD)\n",
|
--licence=LICENCE Set the program licence (default BSD)\n",
|
||||||
stdout);
|
stdout);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user