File tree Expand file tree Collapse file tree 2 files changed +26
-18
lines changed Expand file tree Collapse file tree 2 files changed +26
-18
lines changed Original file line number Diff line number Diff line change @@ -28,8 +28,14 @@ impl Client {
28
28
. inner
29
29
. get ( "https://api.surveyhero.com/v1/surveys" )
30
30
. basic_auth ( & self . username , Some ( & self . password ) )
31
- . send ( ) ?
32
- . error_for_status ( ) ?;
31
+ . send ( ) ?;
32
+ let status = response. status ( ) ;
33
+ if !status. is_success ( ) {
34
+ let text = response. text ( ) ?;
35
+ return Err ( anyhow:: anyhow!(
36
+ "HTTP error status {status} while fetching surveys:\n {text}"
37
+ ) ) ;
38
+ }
33
39
let surveys: Surveys = response. json ( ) ?;
34
40
Ok ( surveys. surveys )
35
41
}
Original file line number Diff line number Diff line change @@ -15,20 +15,22 @@ fn main() -> anyhow::Result<()> {
15
15
let args = Args :: parse ( ) ;
16
16
let online_data = fetch_surveyhero_data ( args. cmd . shared ( ) ) ?;
17
17
18
- let base_path = PathBuf :: from ( format ! (
19
- "../surveys/{}-annual-survey" ,
20
- args. cmd. shared( ) . year
21
- ) ) ;
22
- let mut pairs = vec ! [ ( base_path. join( "questions.md" ) , online_data. main) ] ;
23
- for ( language, questions) in online_data. secondary_languages {
24
- pairs. push ( (
25
- base_path
26
- . join ( "translations" )
27
- . join ( language)
28
- . with_extension ( "md" ) ,
29
- questions,
30
- ) ) ;
31
- }
18
+ let base_path = PathBuf :: from ( format ! ( "../surveys/{}" , args. cmd. shared( ) . path) ) ;
19
+ let pairs = if base_path. is_dir ( ) {
20
+ let mut pairs = vec ! [ ( base_path. join( "questions.md" ) , online_data. main) ] ;
21
+ for ( language, questions) in online_data. secondary_languages {
22
+ pairs. push ( (
23
+ base_path
24
+ . join ( "translations" )
25
+ . join ( language)
26
+ . with_extension ( "md" ) ,
27
+ questions,
28
+ ) ) ;
29
+ }
30
+ pairs
31
+ } else {
32
+ vec ! [ ( base_path, online_data. main) ]
33
+ } ;
32
34
33
35
match args. cmd {
34
36
VerifierCmd :: Check { .. } => {
@@ -318,9 +320,9 @@ struct SharedArgs {
318
320
/// Name of the survey.
319
321
#[ clap( long) ]
320
322
survey_name : String ,
321
- /// Year of the survey . Corresponds to `surveys/<year>-annual-survey` directory .
323
+ /// Survey path . Corresponds to a Markdown file or a directory at `surveys/<path>` .
322
324
#[ clap( long) ]
323
- year : u32 ,
325
+ path : String ,
324
326
}
325
327
326
328
#[ derive( clap:: Parser , Clone ) ]
You can’t perform that action at this time.
0 commit comments