-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
posix.clj
27 lines (22 loc) · 796 Bytes
/
posix.clj
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
(ns piotr-yuxuan.malli-cli.domain.posix
"Option names are single alphanumeric characters (as for isalnum). For
short options the space or equal character between option and an
option argument is optional; also, several one-character option may
be grouped after one hyphen.")
(defn option?
"Arguments are options if they begin with a hyphen delimiter ('-')."
[s]
(re-find #"^-\p{Alnum}{0,1}" s))
(defn single-option?
"A option argument may follow the single-character option name. This
can become rather counterintuitive with single-character option -."
[s]
(re-find #"^-\p{Alnum}{0,1}" s))
(defn single-option-without-value?
[s]
(re-find #"^-\p{Alnum}{0,1}$" s))
(defn grouped-options?
[s]
(re-find #"(?<=^-{1})\p{Alnum}{2,}" s))
(def option-terminator
"--")