File tree 5 files changed +57
-14
lines changed
5 files changed +57
-14
lines changed Original file line number Diff line number Diff line change @@ -108,5 +108,25 @@ jobs:
108
108
uses : ./
109
109
with :
110
110
outputs : ${{ toJSON(steps.changed-files.outputs) }}
111
- directory : test/output
112
- keys : " added_files copied_files deleted_files modified_files"
111
+ keys : |
112
+ added_files
113
+ copied_files
114
+ deleted_files
115
+ modified_files
116
+ renamed_files
117
+ all_old_new_renamed_files
118
+ type_changed_files
119
+ unmerged_files
120
+ unknown_files
121
+ all_changed_and_modified_files
122
+ all_changed_files
123
+ any_changed
124
+ only_changed
125
+ other_changed_files
126
+ all_modified_files
127
+ any_modified
128
+ only_modified
129
+ other_modified_files
130
+ any_deleted
131
+ only_deleted
132
+ other_deleted_files
Original file line number Diff line number Diff line change @@ -12,4 +12,6 @@ Cargo.lock
12
12
** /* .rs.bk
13
13
14
14
# JetBrains IDEs
15
- .idea /
15
+ .idea /
16
+
17
+ test /
Original file line number Diff line number Diff line change @@ -5,12 +5,12 @@ inputs:
5
5
directory :
6
6
description : " Directory to write to"
7
7
required : true
8
- default : " outputs"
8
+ default : " .github/ outputs"
9
9
outputs :
10
10
description : " JSON string"
11
11
required : true
12
12
keys :
13
- description : " List of Keys to read from the outputs. Example: foo,bar "
13
+ description : " List of Keys to read from the outputs."
14
14
required : true
15
15
extension :
16
16
description : " File extension to use"
Original file line number Diff line number Diff line change 2
2
set -euo pipefail
3
3
4
4
INPUT_OUTPUTS=" $( echo " $INPUT_OUTPUTS " | jq -r @json) "
5
+ INPUT_KEYS=" $( echo " $INPUT_KEYS " | tr ' \n' ' ' | xargs) "
5
6
6
7
if [[ -z " $INPUT_BIN_PATH " ]]; then
7
8
# # TODO: use "curl -sf https://[github releases - latest]] | PREFIX=. sh"
8
9
exit 1;
9
10
fi
10
11
11
- echo " ::debug:: Generating output using $INPUT_BIN_PATH ..."
12
+ echo " Generating output using $INPUT_BIN_PATH ..."
12
13
13
- $INPUT_BIN_PATH --keys=" $INPUT_KEYS " --outputs=" $INPUT_OUTPUTS " \
14
- --directory=" $INPUT_DIRECTORY " --extension=" $INPUT_EXTENSION " && exit_status=$? || exit_status=$?
14
+ $INPUT_BIN_PATH --keys=" $INPUT_KEYS " --outputs=" $INPUT_OUTPUTS " --directory=" $INPUT_DIRECTORY " --extension=" $INPUT_EXTENSION " && exit_status=$? || exit_status=$?
15
15
16
16
rm -f " $INPUT_BIN_PATH "
17
17
18
18
if [[ $exit_status -ne 0 ]]; then
19
19
echo " ::error::Error generating output files from JSON"
20
- exit $exit_status ;
20
+ exit 1 ;
21
21
fi
Original file line number Diff line number Diff line change @@ -87,17 +87,27 @@ fn get_args_as_bool(pattern: &str) -> bool {
87
87
fn parse_keys ( ) -> Result < Vec < String > , String > {
88
88
let keys: Vec < String > = get_args_as_vec ( r"^(--keys|-k)=" ) ;
89
89
// Split the keys by commas or spaces or newlines
90
- let re: regex:: Regex = regex:: Regex :: new ( r"[,\s\\n ]+" ) . unwrap ( ) ;
90
+ let re: regex:: Regex = regex:: Regex :: new ( r"[[:space:] ]+" ) . unwrap ( ) ;
91
91
let mut output: Vec < String > = Vec :: new ( ) ;
92
92
93
+ println ! ( "Keys: {:?}" , keys) ;
94
+
93
95
if keys. is_empty ( ) {
94
96
Err ( "No keys provided, Please specify at least one key using --key=[KEY_NAME] or -k=[KEY_NAME]." . to_string ( ) )
95
97
} else {
96
98
for key in keys {
97
- if re. is_match ( & key) {
98
- output. extend ( re. split ( & key) . map ( |s| s. trim ( ) . to_string ( ) ) ) ;
99
- } else if !key. is_empty ( ) {
100
- output. push ( key. trim ( ) . to_string ( ) ) ;
99
+ if !key. is_empty ( ) {
100
+ output. extend ( re. split ( & key) . filter_map ( |s| {
101
+ if s. is_empty ( ) {
102
+ None
103
+ } else {
104
+ Some ( s. trim ( ) . to_string ( ) )
105
+ }
106
+ } ) ) ;
107
+
108
+ println ! ( "Output: {:?}" , output) ;
109
+ } else {
110
+ Err ( "Invalid key provided, Please specify at least one key using --key=[KEY_NAME] or -k=[KEY_NAME]." . to_string ( ) ) ?;
101
111
}
102
112
}
103
113
Ok ( output)
@@ -207,6 +217,17 @@ fn options_valid() -> bool {
207
217
true
208
218
}
209
219
220
+ // TODO: Switch to use https://rust-cli.github.io/book/tutorial/index.html
221
+ // #[derive(Parser)]
222
+ // struct Options {
223
+ // help: bool,
224
+ // version: bool,
225
+ // keys: Vec<String>,
226
+ // outputs: String,
227
+ // directory: String,
228
+ // extension: String,
229
+ // }
230
+
210
231
fn main ( ) {
211
232
if !options_valid ( ) {
212
233
std:: process:: exit ( 1 ) ;
You can’t perform that action at this time.
0 commit comments