|
10 | 10 |
|
11 | 11 | app = typer.Typer( |
12 | 12 | name="MyoQuant", |
13 | | - add_completion=True, |
| 13 | + add_completion=False, |
14 | 14 | help="MyoQuant Analysis Command Line Interface", |
15 | 15 | pretty_exceptions_show_locals=False, |
16 | 16 | ) |
17 | 17 |
|
18 | 18 |
|
19 | | -def check_file_exists(ctx: typer.Context, path): |
20 | | - if ctx.resilient_parsing: |
21 | | - return |
22 | | - if path is None: |
23 | | - return path |
24 | | - if not path.exists(): |
25 | | - console.print(f"The path you've supplied {path} does not exist.", style="red") |
26 | | - raise typer.Exit(code=1) |
27 | | - return path |
28 | | - |
29 | | - |
30 | 19 | @app.command() |
31 | 20 | def sdh_analysis( |
32 | 21 | image_path: Path = typer.Argument( |
33 | | - ..., help="The image file path to analyse.", callback=check_file_exists |
| 22 | + ..., |
| 23 | + help="The image file path to analyse.", |
| 24 | + exists=True, |
| 25 | + file_okay=True, |
| 26 | + dir_okay=False, |
| 27 | + writable=False, |
| 28 | + readable=True, |
| 29 | + resolve_path=True, |
34 | 30 | ), |
35 | 31 | mask_path: Path = typer.Option( |
36 | 32 | None, |
37 | 33 | help="The path to a binary mask to hide slide region during analysis.", |
38 | | - callback=check_file_exists, |
| 34 | + exists=True, |
| 35 | + file_okay=True, |
| 36 | + dir_okay=False, |
| 37 | + writable=False, |
| 38 | + readable=True, |
| 39 | + resolve_path=True, |
39 | 40 | ), |
40 | 41 | model_path: Path = typer.Option( |
41 | 42 | None, |
42 | 43 | help="The SDH model path to use for analysis. Will download latest one if no path provided.", |
43 | | - callback=check_file_exists, |
| 44 | + exists=True, |
| 45 | + file_okay=True, |
| 46 | + dir_okay=False, |
| 47 | + writable=False, |
| 48 | + readable=True, |
| 49 | + resolve_path=True, |
44 | 50 | ), |
45 | 51 | cellpose_path: Path = typer.Option( |
46 | 52 | None, |
47 | 53 | help="The pre-computed CellPose mask to use for analysis. Will run Cellpose if no path provided. Required as an image file.", |
48 | | - callback=check_file_exists, |
| 54 | + exists=True, |
| 55 | + file_okay=True, |
| 56 | + dir_okay=False, |
| 57 | + writable=False, |
| 58 | + readable=True, |
| 59 | + resolve_path=True, |
49 | 60 | ), |
50 | 61 | output_path: Path = typer.Option( |
51 | 62 | None, |
@@ -175,22 +186,44 @@ def sdh_analysis( |
175 | 186 | @app.command() |
176 | 187 | def he_analysis( |
177 | 188 | image_path: Path = typer.Argument( |
178 | | - ..., help="The image file path to analyse.", callback=check_file_exists |
| 189 | + ..., |
| 190 | + help="The image file path to analyse.", |
| 191 | + exists=True, |
| 192 | + file_okay=True, |
| 193 | + dir_okay=False, |
| 194 | + writable=False, |
| 195 | + readable=True, |
| 196 | + resolve_path=True, |
179 | 197 | ), |
180 | 198 | mask_path: Path = typer.Option( |
181 | 199 | None, |
182 | 200 | help="The path to a binary mask to hide slide region during analysis.", |
183 | | - callback=check_file_exists, |
| 201 | + exists=True, |
| 202 | + file_okay=True, |
| 203 | + dir_okay=False, |
| 204 | + writable=False, |
| 205 | + readable=True, |
| 206 | + resolve_path=True, |
184 | 207 | ), |
185 | 208 | cellpose_path: Path = typer.Option( |
186 | 209 | None, |
187 | 210 | help="The pre-computed CellPose mask to use for analysis. Will run Cellpose if no path provided. Required as an image file.", |
188 | | - callback=check_file_exists, |
| 211 | + exists=True, |
| 212 | + file_okay=True, |
| 213 | + dir_okay=False, |
| 214 | + writable=False, |
| 215 | + readable=True, |
| 216 | + resolve_path=True, |
189 | 217 | ), |
190 | 218 | stardist_path: Path = typer.Option( |
191 | 219 | None, |
192 | 220 | help="The pre-computed Stardist mask to use for analysis. Will run Stardist if no path provided. Required as an image file.", |
193 | | - callback=check_file_exists, |
| 221 | + exists=True, |
| 222 | + file_okay=True, |
| 223 | + dir_okay=False, |
| 224 | + writable=False, |
| 225 | + readable=True, |
| 226 | + resolve_path=True, |
194 | 227 | ), |
195 | 228 | output_path: Path = typer.Option( |
196 | 229 | None, |
|
0 commit comments