Blame view

tests/arg-parser.t 1.23 KB
cffa56ed7   Shrikant Sharat   Added function to...
1
  Helper alias.
7a2ca5936   Shrikant Sharat   Allow whitespace ...
2
3
    $ alias parse='-antigen-parse-args "url?, loc?;
    >   btype:?, no-local-clone?"'
cffa56ed7   Shrikant Sharat   Added function to...
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
  
  No arguments (since all are specified as optional).
  
    $ parse
     (glob)
  
  One positional argument.
  
    $ parse name
    local url='name'
  
  Two arguments.
  
    $ parse url location
    local url='url'
    local loc='location'
  
  Three arguments.
  
    $ parse url location crap
    Only 2 positional arguments allowed.
    Found at least one more: 'crap'
  
  Keywordo magic.
  
    $ parse url location --btype=1 --no-local-clone
    local url='url'
    local loc='location'
    local btype='1'
    local no_local_clone='true'
  
  Unknown keyword argument.
  
    $ parse --me=genius
    Unknown argument 'me'.
  
  Missed value for keyword argument.
  
    $ parse --btype
    Required argument for 'btype' not provided.
  
  Provide value for keyword argument, that shouldn't be there.
  
    $ parse --no-local-clone=yes
    No argument required for 'no-local-clone', but provided 'yes'.
973558eee   Shrikant Sharat   Support positiona...
49
50
51
52
53
  
  Positional argument as a keyword argument.
  
    $ parse --url=some-url
    local url='some-url'
9d1b71736   Shrikant Sharat   Detect repeated a...
54
55
56
57
58
59
60
61
62
63
  
  Repeated keyword arguments.
  
    $ parse --url=url1 --url=url2
    Argument 'url' repeated with the value 'url2'.
  
  Repeated, once as positional and once more as keyword.
  
    $ parse url1 --url=url2
    Argument 'url' repeated with the value 'url2'.