fast-dev-cli 0.25.6__tar.gz → 0.25.8__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: fast-dev-cli
3
- Version: 0.25.6
3
+ Version: 0.25.8
4
4
  Summary: Python project development tool.
5
5
  Author-Email: Waket Zheng <waketzheng@gmail.com>>
6
6
  Classifier: Development Status :: 4 - Beta
@@ -0,0 +1 @@
1
+ __version__ = "0.25.8"
@@ -1269,7 +1269,11 @@ class LintCode(DryRun):
1269
1269
  path_args = ["."]
1270
1270
  quoted_paths = _join_shell_args(path_args)
1271
1271
  if path_args != ["."] and all(i.endswith(".html") for i in path_args):
1272
- return f"prettier -w {quoted_paths}"
1272
+ prettier = "prettier"
1273
+ if is_windows() and (abspath := shutil.which(prettier)):
1274
+ # If prettier is installed by `npm i -g`
1275
+ prettier = Path(abspath).name # prettier.CMD
1276
+ return f"{prettier} -w {quoted_paths}"
1273
1277
  ruff_rules = ["I", "B"]
1274
1278
  if ruff_check_sim and not load_bool("FASTDEVCLI_NO_SIM"):
1275
1279
  ruff_rules.append("SIM")
@@ -2225,7 +2229,7 @@ class UvPypi(DryRun):
2225
2229
 
2226
2230
  @cli.command()
2227
2231
  def pypi(
2228
- file: str | None = typer.Argument(default=None),
2232
+ file: Annotated[str | None, typer.Argument()] = None,
2229
2233
  dry: bool = DryOption,
2230
2234
  verbose: bool = False,
2231
2235
  quiet: bool = False,
@@ -2241,6 +2245,65 @@ def pypi(
2241
2245
  UvPypi(p, dry, verbose, quiet, slim, reverse).run()
2242
2246
 
2243
2247
 
2248
+ class SuffixParser:
2249
+ usually = ("py", "md", "json", "txt", "proto", "toml")
2250
+
2251
+ @classmethod
2252
+ def fill(cls, files: list[str]) -> list[str]:
2253
+ names = []
2254
+ for f in files:
2255
+ if f.endswith("."):
2256
+ f = cls.guess(f)
2257
+ else:
2258
+ p = Path(f)
2259
+ if not Path(f).suffix and not p.exists():
2260
+ f = cls.guess(f, ".")
2261
+ names.append(f)
2262
+ return names
2263
+
2264
+ @classmethod
2265
+ def guess(cls, file: str, sep: str = "") -> str:
2266
+ for s in cls.usually:
2267
+ f = file + sep + s
2268
+ if os.path.exists(f):
2269
+ return f
2270
+ p = Path(file)
2271
+ d = p.parent
2272
+ ff = list(d.glob(p.name + sep + "*"))
2273
+ match len(ff):
2274
+ case 0:
2275
+ ...
2276
+ case 1:
2277
+ return ff[0].as_posix()
2278
+ case _:
2279
+ typer.echo(f"Found several match files: {ff}")
2280
+ return file
2281
+
2282
+
2283
+ @cli.command()
2284
+ def vi(
2285
+ files: Annotated[list[str], typer.Argument()],
2286
+ dry: Annotated[
2287
+ bool, Option(help="Only print, not really run shell command")
2288
+ ] = False,
2289
+ vertical: Annotated[bool | None, Option(..., "-O", help="Open vertically")] = None,
2290
+ horizon: Annotated[bool | None, Option(..., "-o", help="Open horizontally")] = None,
2291
+ guess: Annotated[
2292
+ bool, Option(help="Whether guess file suffix if not exist")
2293
+ ] = True,
2294
+ ) -> None:
2295
+ cmd = "vim "
2296
+ if len(files) > 1:
2297
+ if horizon:
2298
+ cmd += "-o "
2299
+ elif vertical is not False:
2300
+ cmd += "-O "
2301
+ if guess:
2302
+ files = SuffixParser.fill(files)
2303
+ cmd += " ".join(files)
2304
+ exit_if_run_failed(cmd, dry=dry)
2305
+
2306
+
2244
2307
  def version_callback(value: bool) -> None:
2245
2308
  if value:
2246
2309
  echo("Fast Dev Cli Version: " + typer.style(__version__, bold=True))
@@ -2249,14 +2312,16 @@ def version_callback(value: bool) -> None:
2249
2312
 
2250
2313
  @cli.callback()
2251
2314
  def common(
2252
- version: bool = Option(
2253
- None,
2254
- "--version",
2255
- "-V",
2256
- callback=version_callback,
2257
- is_eager=True,
2258
- help="Show the version of this tool",
2259
- ),
2315
+ version: Annotated[
2316
+ bool | None,
2317
+ Option(
2318
+ ...,
2319
+ *("--version", "-V"),
2320
+ callback=version_callback,
2321
+ is_eager=True,
2322
+ help="Show the version of this tool",
2323
+ ),
2324
+ ] = None,
2260
2325
  ) -> None: ...
2261
2326
 
2262
2327
 
@@ -29,7 +29,7 @@ dependencies = [
29
29
  "typer>=0.24.0,<1",
30
30
  "tomli >=2.0.1,<3; python_version < '3.11'",
31
31
  ]
32
- version = "0.25.6"
32
+ version = "0.25.8"
33
33
 
34
34
  [project.urls]
35
35
  Homepage = "https://github.com/waketzheng/fast-dev-cli"
@@ -55,6 +55,7 @@ dev = [
55
55
  "asynctor>=0.13.0",
56
56
  "httpx2>=2.5.0",
57
57
  "tomli-w>=1.2.0",
58
+ "twine>=7.0.0",
58
59
  ]
59
60
 
60
61
  [build-system]
@@ -1 +0,0 @@
1
- __version__ = "0.25.6"
File without changes
File without changes