Skip to content

Commit cd8ba31

Browse files
committed
Add version option
1 parent 08fa84f commit cd8ba31

File tree

4 files changed

+25
-6
lines changed

4 files changed

+25
-6
lines changed

src/evid.c

+7-3
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
along with this program. If not, see <https://www.gnu.org/licenses/>.
1717
**/
1818

19+
#include "evid.h"
1920
#include "actions.h"
2021
#include "clipboard.h"
2122
#include "file.h"
@@ -44,8 +45,6 @@
4445
#include <linux/limits.h>
4546
#include <sys/wait.h>
4647

47-
#define PROGRAM_NAME "evid"
48-
4948
#define GRAB(dpy, window) grab_keys(dpy, window, SAVE | COPY)
5049
#define UNGRAB(dpy, window) ungrab_keys(dpy, window, SAVE | COPY)
5150

@@ -88,10 +87,11 @@ static void process_args(Args *args, int argc, char **argv) {
8887
{"audio", optional_argument, NULL, 'a'},
8988
{"output", required_argument, NULL, 'o'},
9089
{"help", no_argument, NULL, 'h'},
90+
{"version", no_argument, NULL, 'v'},
9191
{NULL, 0, NULL, 0}};
9292

9393
int opt;
94-
while ((opt = getopt_long(argc, argv, "idzgo:f:a::h", long_opts, NULL)) !=
94+
while ((opt = getopt_long(argc, argv, "idzgo:f:a::hv", long_opts, NULL)) !=
9595
-1) {
9696
switch (opt) {
9797
case ('i'): {
@@ -143,6 +143,10 @@ static void process_args(Args *args, int argc, char **argv) {
143143
}
144144
break;
145145
}
146+
case ('v'): {
147+
print_version();
148+
exit(EXIT_SUCCESS);
149+
}
146150
case ('h'): {
147151
print_usage();
148152
exit(EXIT_SUCCESS);

src/evid.h

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#ifndef EVID_H
2+
#define EVID_H
3+
4+
#define PROGRAM_NAME "evid"
5+
#define PROGRAM_VERSION "0.0.1"
6+
7+
#endif

src/util.c

+8-2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
**/
1818

1919
#include "util.h"
20+
#include "evid.h"
2021

2122
#ifdef HAVE_NOTIFY
2223
#include "libnotify/notify.h"
@@ -63,7 +64,11 @@ void die(const char *errstr, ...) {
6364
raise(SIGINT);
6465
}
6566

66-
void print_usage() {
67+
void print_version(void) {
68+
fprintf(stdout, "%s version %s\n", PROGRAM_NAME, PROGRAM_VERSION);
69+
}
70+
71+
void print_usage(void) {
6772
fprintf(
6873
stdout,
6974
"Usage: %s [OPTIONS] \n Available options:\n -i|--info\toutput "
@@ -73,7 +78,8 @@ void print_usage() {
7378
"valid options are pulse and alsa with a comma separated input device, "
7479
"defaults to pulse,default.\n --no-draw-mouse\thides the pointer in the "
7580
"output video.\n -g|--gif\toutputs the recording to a gif\n "
76-
"-o|--output\tsaves the recording into this file or directory\n"
81+
"-o|--output\tsaves the recording into this file or directory\n "
82+
"-v|--version show program version\n"
7783
#ifdef HAVE_ZENITY
7884
" -z|--use-zenity\tuses a file selection dialog "
7985
"from zenity instead of a default path to save the output "

src/util.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,14 @@
1919
#ifndef EVID_UTIL_H
2020
#define EVID_UTIL_H
2121

22-
#define PROGRAM_NAME "evid"
22+
#include "evid.h"
23+
2324
#define ARR_SIZE(arr) (sizeof(arr) / sizeof(*arr))
2425

2526
void error(const char *errstr, ...);
2627
void die(const char *errstr, ...);
2728

29+
void print_version(void);
2830
void print_usage(void);
2931

3032
#endif

0 commit comments

Comments
 (0)