Added -v option to show uwufetch version
This commit is contained in:
parent
edc3ac96ca
commit
82bdbe4cbd
2 changed files with 18 additions and 8 deletions
5
Makefile
5
Makefile
|
@ -1,7 +1,8 @@
|
||||||
NAME = uwufetch
|
NAME = uwufetch
|
||||||
FILES = uwufetch.c
|
FILES = uwufetch.c
|
||||||
CFLAGS = -O3
|
UWUFETCH_VERSION = UWUFETCH_VERSION="\"$(shell git describe --tags)\""
|
||||||
CFLAGS_DEBUG = -Wall -Wextra -g -pthread
|
CFLAGS = -O3 -D$(UWUFETCH_VERSION)
|
||||||
|
CFLAGS_DEBUG = -Wall -Wextra -g -pthread -D$(UWUFETCH_VERSION)
|
||||||
CC = cc
|
CC = cc
|
||||||
DESTDIR = /usr
|
DESTDIR = /usr
|
||||||
PLATFORM = $(shell uname)
|
PLATFORM = $(shell uname)
|
||||||
|
|
15
uwufetch.c
15
uwufetch.c
|
@ -13,6 +13,10 @@
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifndef UWUFETCH_VERSION
|
||||||
|
#define UWUFETCH_VERSION "unkown" // needs to be changed by the build script
|
||||||
|
#endif
|
||||||
|
|
||||||
#define _GNU_SOURCE // for strcasestr
|
#define _GNU_SOURCE // for strcasestr
|
||||||
|
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
|
@ -163,7 +167,7 @@ struct configuration parse_config(struct info* user_info) {
|
||||||
sprintf(homedir, "%s/.config/uwufetch/config", getenv("HOME"));
|
sprintf(homedir, "%s/.config/uwufetch/config", getenv("HOME"));
|
||||||
config = fopen(homedir, "r");
|
config = fopen(homedir, "r");
|
||||||
if (!config) {
|
if (!config) {
|
||||||
if(getenv("PREFIX") != NULL) {
|
if (getenv("PREFIX") != NULL) {
|
||||||
char prefixed_etc[512];
|
char prefixed_etc[512];
|
||||||
sprintf(prefixed_etc, "%s/etc/uwufetch/config", getenv("PREFIX"));
|
sprintf(prefixed_etc, "%s/etc/uwufetch/config", getenv("PREFIX"));
|
||||||
config = fopen(prefixed_etc, "r");
|
config = fopen(prefixed_etc, "r");
|
||||||
|
@ -1312,6 +1316,7 @@ void usage(char* arg) {
|
||||||
#endif
|
#endif
|
||||||
" read README.md for more info%s\n"
|
" read README.md for more info%s\n"
|
||||||
" -l, --list lists all supported distributions\n"
|
" -l, --list lists all supported distributions\n"
|
||||||
|
" -v, --version prints the current uwufetch version\n"
|
||||||
" -w, --write-cache writes to the cache file (~/.cache/uwufetch.cache)\n"
|
" -w, --write-cache writes to the cache file (~/.cache/uwufetch.cache)\n"
|
||||||
" using the cache set $UWUFETCH_CACHE_ENABLED to TRUE, true or 1\n",
|
" using the cache set $UWUFETCH_CACHE_ENABLED to TRUE, true or 1\n",
|
||||||
arg,
|
arg,
|
||||||
|
@ -1361,10 +1366,11 @@ int main(int argc, char* argv[]) {
|
||||||
{"config", required_argument, NULL, 'c'},
|
{"config", required_argument, NULL, 'c'},
|
||||||
// {"cache", no_argument, NULL, 'C'}, // using an environment variable is not a good idea, maybe some time in the future, uwufetch will use a command line option
|
// {"cache", no_argument, NULL, 'C'}, // using an environment variable is not a good idea, maybe some time in the future, uwufetch will use a command line option
|
||||||
{"distro", required_argument, NULL, 'd'},
|
{"distro", required_argument, NULL, 'd'},
|
||||||
{"write-cache", no_argument, NULL, 'w'},
|
|
||||||
{"help", no_argument, NULL, 'h'},
|
{"help", no_argument, NULL, 'h'},
|
||||||
{"image", optional_argument, NULL, 'i'},
|
{"image", optional_argument, NULL, 'i'},
|
||||||
{"list", no_argument, NULL, 'l'},
|
{"list", no_argument, NULL, 'l'},
|
||||||
|
{"version", no_argument, NULL, 'v'},
|
||||||
|
{"write-cache", no_argument, NULL, 'w'},
|
||||||
{NULL, 0, NULL, 0}};
|
{NULL, 0, NULL, 0}};
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
@ -1375,7 +1381,7 @@ int main(int argc, char* argv[]) {
|
||||||
config_flags = parse_config(&user_info); // same as user_info
|
config_flags = parse_config(&user_info); // same as user_info
|
||||||
|
|
||||||
// reading cmdline options
|
// reading cmdline options
|
||||||
while ((opt = getopt_long(argc, argv, "ac:d:hi::lw", long_options, NULL)) != -1) {
|
while ((opt = getopt_long(argc, argv, "ac:d:hi::lvw", long_options, NULL)) != -1) {
|
||||||
switch (opt) {
|
switch (opt) {
|
||||||
case 'a': // set ascii logo as output
|
case 'a': // set ascii logo as output
|
||||||
config_flags.ascii_image_flag = 0;
|
config_flags.ascii_image_flag = 0;
|
||||||
|
@ -1399,6 +1405,9 @@ int main(int argc, char* argv[]) {
|
||||||
case 'l':
|
case 'l':
|
||||||
list(argv[0]);
|
list(argv[0]);
|
||||||
return 0;
|
return 0;
|
||||||
|
case 'v':
|
||||||
|
printf("UwUfetch version %s\n", UWUFETCH_VERSION);
|
||||||
|
return 0;
|
||||||
case 'w':
|
case 'w':
|
||||||
write_cache(&user_info);
|
write_cache(&user_info);
|
||||||
if (print_cache(&config_flags, &user_info) < 7)
|
if (print_cache(&config_flags, &user_info) < 7)
|
||||||
|
|
Loading…
Reference in a new issue