aboutsummaryrefslogtreecommitdiff
path: root/src/help.c
blob: e35cbcc68be318bb85bc533c08b729097695920b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/*

  pkgit - package it!

  Copyright (C) 2026 dacctal
  This program is free software: you can REDistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation, either version 2 of the License, or
  (at your option) any later version.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program.  If not, see <https://www.gnu.org/licenses/>.

*/

#include <stdio.h>

#include "common.h"
#include "help.h"
#include "state.h"

void print_help(void) {
	typedef struct {
		const char *short_flag;
		const char *long_flag;
		const char *arg;
		const char *desc;
	} flag_t;

	static const flag_t cmd_flags[] = {
		{"-a", "--add", "[url]", "add a repo"},
		{"-b", "--build", "[path]", "build a package"},
		{"-d", "--declare", "", "install all packages"},
		{"-s", "--search", "[pkgs]", "find a package from your repos"},
		{"-i", "--install", "[pkgs, urls]", "install a package/repo"},
		{"-r", "--remove", "[pkgs]", "remove an installed package"},
		{"-l", "--list", "", "list all installed packages"},
		{"-u", "--update", "", "update all installed packages"},
		{"-h", "--help", "", "display this help message"},
		{"-v", "--version", "", "display version number"},
		{"-c", "--check", "", "run package checks"},
	};

	static const flag_t mod_flags[] = {
		{"-q", "--quiet", "", "add a repo"},
		{"-f", "--force", "", "build a package"},
	};

	if (!flags.quiet) {
		printf(BOLD_MAGENTA "      ,        \n");
		printf(BOLD_MAGENTA "     / \\       \n");
		printf(BOLD_MAGENTA "_.--'   '--._  \n");
		printf(BOLD_MAGENTA "`'--,   ,--'`  " COLOR_RESET "pkgit " ITALIC GRAY
							"- package it!" COLOR_RESET "\n");
		printf(BOLD_YELLOW " _-  " BOLD_MAGENTA "\\ /" BOLD_YELLOW
						   "  -_   " MAGENTA VERSION COLOR_RESET "\n");
		printf(BOLD_YELLOW "'-_   " BOLD_MAGENTA "'" BOLD_YELLOW "   _-'  \n");
		printf(BOLD_YELLOW "   `'-.-'`     " COLOR_RESET "\n");
	} else {
		printf(BOLD "pkgit " COLOR_RESET ITALIC GRAY "- package it!" COLOR_RESET
					"\n");
		printf("version " MAGENTA VERSION COLOR_RESET "\n");
	}
	printf("\n");

	printf(RED "subcommand flags" COLOR_RESET ":\n");
	for (size_t i = 0; i < LENGTH(cmd_flags); i++) {
		printf(COLOR_RESET "  " GREEN "%-2s" COLOR_RESET ", " YELLOW
						   "%-12s" BLUE "%-16s" GRAY "# %s\n" COLOR_RESET,
			   cmd_flags[i].short_flag, cmd_flags[i].long_flag,
			   cmd_flags[i].arg, cmd_flags[i].desc);
	}

	printf("\n" RED "modifier flags" COLOR_RESET ":\n");
	for (size_t i = 0; i < LENGTH(mod_flags); i++) {
		printf(COLOR_RESET "  " GREEN "%-2s" COLOR_RESET ", " YELLOW
						   "%-12s" BLUE "%-16s" GRAY "# %s\n" COLOR_RESET,
			   mod_flags[i].short_flag, mod_flags[i].long_flag,
			   mod_flags[i].arg, mod_flags[i].desc);
	}
}