Skip to content

Commit 655d197

Browse files
author
Corentin
committed
Remove autocompletion, path bugged
1 parent 6d21ba9 commit 655d197

File tree

2 files changed

+54
-22
lines changed

2 files changed

+54
-22
lines changed

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ Using pip, you can simply install MyoQuant in a python environment with a simple
3131
## How to Use
3232

3333
To use the command-line tool, first activate your venv in which MyoQuant is installed: `source .venv/bin/activate`
34-
Then you can perform SDH or HE analysis. You can use the command `myoquant --help` to list available commands.
35-
💡 For confort, you can run `myoquant --install-completion [bash|zsh|fish|powershell|pwsh]` to install auto-completion for the commands and arguments ! 🙂
34+
Then you can perform SDH or HE analysis. You can use the command `myoquant --help` to list available commands.
3635

3736
- **For SDH Image Analysis** the command is:
3837
`myoquant sdh-analysis IMAGE_PATH`

myoquant/__main__.py

Lines changed: 53 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,42 +10,53 @@
1010

1111
app = typer.Typer(
1212
name="MyoQuant",
13-
add_completion=True,
13+
add_completion=False,
1414
help="MyoQuant Analysis Command Line Interface",
1515
pretty_exceptions_show_locals=False,
1616
)
1717

1818

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-
3019
@app.command()
3120
def sdh_analysis(
3221
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,
3430
),
3531
mask_path: Path = typer.Option(
3632
None,
3733
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,
3940
),
4041
model_path: Path = typer.Option(
4142
None,
4243
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,
4450
),
4551
cellpose_path: Path = typer.Option(
4652
None,
4753
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,
4960
),
5061
output_path: Path = typer.Option(
5162
None,
@@ -175,22 +186,44 @@ def sdh_analysis(
175186
@app.command()
176187
def he_analysis(
177188
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,
179197
),
180198
mask_path: Path = typer.Option(
181199
None,
182200
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,
184207
),
185208
cellpose_path: Path = typer.Option(
186209
None,
187210
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,
189217
),
190218
stardist_path: Path = typer.Option(
191219
None,
192220
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,
194227
),
195228
output_path: Path = typer.Option(
196229
None,

0 commit comments

Comments
 (0)