Add long options support
This commit is contained in:
parent
383abb2aa0
commit
6f592e3f4a
1 changed files with 11 additions and 1 deletions
12
uwufetch.c
12
uwufetch.c
|
@ -18,6 +18,7 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <getopt.h>
|
||||||
#include <sys/sysinfo.h>
|
#include <sys/sysinfo.h>
|
||||||
#include <sys/utsname.h>
|
#include <sys/utsname.h>
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
|
@ -57,8 +58,17 @@ void remove_brackets(char*);
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
int opt = 0;
|
int opt = 0;
|
||||||
|
static struct option long_options[] = {
|
||||||
|
{"ascii", no_argument, NULL, 'a'},
|
||||||
|
{"custom", required_argument, NULL, 'c'},
|
||||||
|
{"distro", required_argument, NULL, 'd'},
|
||||||
|
{"help", no_argument, NULL, 'h'},
|
||||||
|
{"image", no_argument, NULL, 'i'},
|
||||||
|
{"list", no_argument, NULL, 'l'},
|
||||||
|
{NULL, 0, NULL, 0}
|
||||||
|
};
|
||||||
get_info();
|
get_info();
|
||||||
while((opt = getopt(argc, argv, "ad:hilc:")) != -1) {
|
while((opt = getopt_long(argc, argv, "ad:hilc:", long_options, NULL)) != -1) {
|
||||||
switch(opt) {
|
switch(opt) {
|
||||||
case 'a':
|
case 'a':
|
||||||
a_i_flag = 0;
|
a_i_flag = 0;
|
||||||
|
|
Loading…
Reference in a new issue