@@ -13,29 +13,14 @@ defmodule Algora.Github.Command do
13
13
attempt: "/attempt <issue-ref> (e.g. #123, repo#123, owner/repo#123, or full GitHub URL)"
14
14
}
15
15
16
- def commands do
17
- repeat (
18
- choice ( [
19
- # Any text that is not a command
20
- [ not: ?/ ] |> utf8_string ( min: 1 ) |> ignore ( ) ,
21
-
22
- # Known command
23
- choice ( [
24
- bounty_command ( ) ,
25
- tip_command ( ) ,
26
- claim_command ( ) ,
27
- split_command ( ) ,
28
- attempt_command ( )
29
- ] ) ,
30
-
31
- # Unknown command
32
- "/"
33
- |> string ( )
34
- |> ignore ( )
35
- |> concat ( utf8_string ( [ ?a .. ?z , ?A .. ?Z , ?_ , ?- ] , min: 1 ) )
36
- |> ignore ( )
37
- ] )
38
- )
16
+ def command do
17
+ choice ( [
18
+ bounty_command ( ) ,
19
+ tip_command ( ) ,
20
+ claim_command ( ) ,
21
+ split_command ( ) ,
22
+ attempt_command ( )
23
+ ] )
39
24
end
40
25
41
26
def bounty_command do
@@ -91,6 +76,16 @@ defmodule Algora.Github.Command do
91
76
|> tag ( :attempt )
92
77
|> label ( @ usage . attempt )
93
78
end
79
+
80
+ def commands do
81
+ repeat (
82
+ choice ( [
83
+ ignore ( utf8_string ( [ not: ?/ ] , min: 1 ) ) ,
84
+ command ( ) ,
85
+ ignore ( string ( "/" ) )
86
+ ] )
87
+ )
88
+ end
94
89
end
95
90
96
91
defparsec ( :parse_raw , Helper . commands ( ) )
@@ -99,14 +94,8 @@ defmodule Algora.Github.Command do
99
94
100
95
def parse ( input ) when is_binary ( input ) do
101
96
case parse_raw ( input ) do
102
- { :ok , parsed , _ , _ , _ , _ } ->
103
- { :ok , Enum . reject ( parsed , & is_nil / 1 ) }
104
-
105
- { :error , reason , _ , _ , _ , _ } ->
106
- { :error , reason }
97
+ { :ok , parsed , _ , _ , _ , _ } -> { :ok , Enum . reject ( parsed , & is_nil / 1 ) }
98
+ { :error , reason , _ , _ , _ , _ } -> { :error , reason }
107
99
end
108
- rescue
109
- ArgumentError ->
110
- { :error , "Failed to parse commands" }
111
100
end
112
101
end
0 commit comments