@@ -22,18 +22,19 @@ def setup(path: str, quiet: bool) -> Tuple[str, PAPath]:
2222
2323@app .command ()
2424def get (
25- path : str = typer .Argument (..., help = "Path to PythonAnywhere file or directory" ),
26- only_files : bool = typer .Option (False , "-f" , "--files" , help = "List only files" ),
27- only_dirs : bool = typer .Option (False , "-d" , "--dirs" , help = "List only directories" ),
28- sort_by_type : bool = typer .Option (False , "-t" , "--type" , help = "Sort by type" ),
29- sort_reverse : bool = typer .Option (False , "-r" , "--reverse" , help = "Sort in reverse order" ),
25+ path : str = typer .Argument (..., help = "Path to PythonAnywhere file or directory. " ),
26+ only_files : bool = typer .Option (False , "-f" , "--files" , help = "List only files. " ),
27+ only_dirs : bool = typer .Option (False , "-d" , "--dirs" , help = "List only directories. " ),
28+ sort_by_type : bool = typer .Option (False , "-t" , "--type" , help = "Sort by type. " ),
29+ sort_reverse : bool = typer .Option (False , "-r" , "--reverse" , help = "Sort in reverse order. " ),
3030 raw : bool = typer .Option (
31- False , "-a" , "--raw" , help = "Print API response (if PATH is file that's the only option) "
31+ False , "-a" , "--raw" , help = "Print API response (has effect only for directories). "
3232 ),
33- quiet : bool = typer .Option (False , "-q" , "--quiet" , help = "Disable additional logging" ),
33+ quiet : bool = typer .Option (False , "-q" , "--quiet" , help = "Disable additional logging. " ),
3434):
3535 """
3636 Get contents of PATH.
37+
3738 If PATH points to a directory, show list of it's contents.
3839 If PATH points to a file, print it's contents.
3940 """
@@ -73,7 +74,7 @@ def _format_tree(data, current):
7374
7475 for entry in reversed (data ):
7576 entry = re .sub (r"/$" , "\0 " , entry .replace (current , "" ))
76- chunks = [cc for cc in entry .split ('/' ) if cc ]
77+ chunks = [cc for cc in entry .split ("/" ) if cc ]
7778 item = chunks [- 1 ].replace ("\0 " , "/" )
7879 level = len (chunks ) - 1
7980 level_tracker = set ([lvl for lvl in level_tracker if lvl <= level ])
@@ -87,9 +88,10 @@ def _format_tree(data, current):
8788
8889@app .command ()
8990def tree (
90- path : str = typer .Argument (..., help = "Path to PythonAnywhere file or directory" ),
91- quiet : bool = typer .Option (False , "-q" , "--quiet" , help = "Disable additional logging" )
91+ path : str = typer .Argument (..., help = "Path to PythonAnywhere directory. " ),
92+ quiet : bool = typer .Option (False , "-q" , "--quiet" , help = "Disable additional logging. " )
9293):
94+ """Show preview of directory contents at PATH in tree-like format (2 levels deep)."""
9395 pa_path = setup (path , quiet )
9496 tree = pa_path .tree
9597
@@ -103,43 +105,49 @@ def tree(
103105
104106@app .command ()
105107def upload (
106- path : str = typer .Argument (
107- ...,
108- help = (
109- "Full path of FILE where CONTENTS should be uploaded to -- "
110- "Warning: if FILE already exists, it's contents will be overwritten"
111- )
112- ),
108+ path : str = typer .Argument (..., help = ("Full path of FILE where CONTENTS should be uploaded to." )),
113109 file : typer .FileBinaryRead = typer .Option (
114110 ...,
115111 "-c" ,
116112 "--contents" ,
117- help = "Path to exisitng file or stdin stream that should be uploaded to PATH"
113+ help = "Path to exisitng file or stdin stream that should be uploaded to PATH. "
118114 ),
119- quiet : bool = typer .Option (False , "-q" , "--quiet" , help = "Disable additional logging" )
115+ quiet : bool = typer .Option (False , "-q" , "--quiet" , help = "Disable additional logging. " )
120116):
117+ """
118+ Upload CONTENTS to file at PATH.
119+
120+ If PATH points to an existing file, it will be overwritten.
121+ """
121122 pa_path = setup (path , quiet )
122123 success = pa_path .upload (file )
123124 sys .exit (0 if success else 1 )
124125
125126
126127@app .command ()
127128def delete (
128- path : str = typer .Argument (..., help = "Path to PythonAnywhere file or directory to be deleted" ),
129- quiet : bool = typer .Option (False , "-q" , "--quiet" , help = "Disable additional logging" )
129+ path : str = typer .Argument (..., help = "Path to PythonAnywhere file or directory to be deleted. " ),
130+ quiet : bool = typer .Option (False , "-q" , "--quiet" , help = "Disable additional logging. " )
130131):
132+ """
133+ Delete file or directory at PATH.
134+
135+ If PATH points to a user owned directory all its contents will be
136+ deleted recursively.
137+ """
131138 pa_path = setup (path , quiet )
132139 success = pa_path .delete ()
133140 sys .exit (0 if success else 1 )
134141
135142
136143@app .command ()
137144def share (
138- path : str = typer .Argument (..., help = "Path to PythonAnywhere file to be shared " ),
139- check : bool = typer .Option (False , "-c" , "--check" , help = "Check sharing status" ),
140- porcelain : bool = typer .Option (False , "-p" , "--porcelain" , help = "Return sharing url in easy-to-parse format" ),
141- quiet : bool = typer .Option (False , "-q" , "--quiet" , help = "Disable logging" ),
145+ path : str = typer .Argument (..., help = "Path to PythonAnywhere file. " ),
146+ check : bool = typer .Option (False , "-c" , "--check" , help = "Check sharing status. " ),
147+ porcelain : bool = typer .Option (False , "-p" , "--porcelain" , help = "Return sharing url in easy-to-parse format. " ),
148+ quiet : bool = typer .Option (False , "-q" , "--quiet" , help = "Disable logging. " ),
142149):
150+ """Create a sharing link to a file at PATH or check its sharing status."""
143151 pa_path = setup (path , quiet or porcelain )
144152 link = pa_path .get_sharing_url () if check else pa_path .share ()
145153
@@ -151,9 +159,10 @@ def share(
151159
152160@app .command ()
153161def unshare (
154- path : str = typer .Argument (..., help = "Path to PythonAnywhere file to be unshared " ),
155- quiet : bool = typer .Option (False , "-q" , "--quiet" , help = "Disable additional logging" )
162+ path : str = typer .Argument (..., help = "Path to PythonAnywhere file. " ),
163+ quiet : bool = typer .Option (False , "-q" , "--quiet" , help = "Disable additional logging. " )
156164):
165+ """Disable sharing link for a file at PATH."""
157166 pa_path = setup (path , quiet )
158167 success = pa_path .unshare ()
159168 sys .exit (0 if success else 1 )
0 commit comments