about summary refs log tree commit diff
diff options
context:
space:
mode:
authorFranck Cuny <franck@fcuny.net>2024-05-04 13:58:58 -0700
committerFranck Cuny <franck@fcuny.net>2024-05-04 13:58:58 -0700
commitb19fca1d9be319f7d7b07215139832f2b46d6385 (patch)
treed4e9afc2fa725c0352f957410fa9e30e749e45e5
parentmove the slocalc under `src` (diff)
downloadworld-b19fca1d9be319f7d7b07215139832f2b46d6385.tar.gz
move seqstat
-rw-r--r--nix/flake/packages.nix6
-rw-r--r--nix/profiles/home-manager/shell.nix1
-rw-r--r--packages/seqstat/default.nix25
-rw-r--r--pyproject.toml2
-rw-r--r--requirements-dev.lock2
-rw-r--r--requirements.lock2
-rwxr-xr-xsrc/cli/seqstat.py (renamed from packages/seqstat/seqstat.py)21
7 files changed, 15 insertions, 44 deletions
diff --git a/nix/flake/packages.nix b/nix/flake/packages.nix
index 3bfbec5..abc12cf 100644
--- a/nix/flake/packages.nix
+++ b/nix/flake/packages.nix
@@ -4,17 +4,11 @@
   ];
 
   perSystem = { config, pkgs, ... }: {
-    overlayAttrs = {
-      inherit (config.packages)
-        seqstat;
-    };
-
     packages = {
       git-blame-stats = pkgs.callPackage "${self}/packages/git-blame-stats" { };
       git-broom = pkgs.callPackage "${self}/packages/git-broom" { };
       ipconverter = pkgs.callPackage "${self}/packages/ipconverter" { };
       robloxenv = pkgs.callPackage "${self}/packages/robloxenv" { };
-      seqstat = pkgs.callPackage "${self}/packages/seqstat" { };
     };
   };
 }
diff --git a/nix/profiles/home-manager/shell.nix b/nix/profiles/home-manager/shell.nix
index 2c3734c..ac41134 100644
--- a/nix/profiles/home-manager/shell.nix
+++ b/nix/profiles/home-manager/shell.nix
@@ -31,7 +31,6 @@
     self.packages.${pkgs.system}.git-blame-stats
     self.packages.${pkgs.system}.git-broom
     self.packages.${pkgs.system}.ipconverter
-    self.packages.${pkgs.system}.seqstat
   ];
 
   xdg = {
diff --git a/packages/seqstat/default.nix b/packages/seqstat/default.nix
deleted file mode 100644
index 96cbd40..0000000
--- a/packages/seqstat/default.nix
+++ /dev/null
@@ -1,25 +0,0 @@
-{ lib, python3, stdenvNoCC }:
-
-stdenvNoCC.mkDerivation rec {
-  pname = "seqstat";
-  src = ./seqstat.py;
-  version = "0.1.0";
-
-  buildInputs = [ python3 ];
-  propagatedBuildInputs = [ python3 ];
-
-  dontUnpack = true;
-  dontBuild = true;
-
-  installPhase = ''
-    mkdir -p $out/bin
-    cp $src $out/bin/${pname}
-  '';
-
-  meta = with lib; {
-    description = "Display an histogram for a given sequence of numbers.";
-    license = with licenses; [ mit ];
-    platforms = platforms.unix;
-    maintainers = with maintainers; [ fcuny ];
-  };
-}
diff --git a/pyproject.toml b/pyproject.toml
index 63545be..0f3dee5 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -8,6 +8,7 @@ dependencies = [
   "requests>=2.31.0",
   "prettytable>=3.10.0",
   "termcolor>=2.4.0",
+  "click>=8.1.7",
 ]
 readme = "README.md"
 requires-python = ">= 3.8"
@@ -66,3 +67,4 @@ known-first-party = ["rbx_nomad"]
 [project.scripts]
 pizza = "cli.pizza:main"
 slocalc = "cli.slocalc:cli"
+seqstat = "cli.seqstat:cli"
diff --git a/requirements-dev.lock b/requirements-dev.lock
index 13ce373..74a56bf 100644
--- a/requirements-dev.lock
+++ b/requirements-dev.lock
@@ -26,6 +26,8 @@ certifi==2024.2.2
     # via requests
 charset-normalizer==3.3.2
     # via requests
+click==8.1.7
+    # via world
 dill==0.3.8
     # via pylint
 docstring-to-markdown==0.15
diff --git a/requirements.lock b/requirements.lock
index ff7b3b3..a2a4254 100644
--- a/requirements.lock
+++ b/requirements.lock
@@ -16,6 +16,8 @@ certifi==2024.2.2
     # via requests
 charset-normalizer==3.3.2
     # via requests
+click==8.1.7
+    # via world
 idna==3.7
     # via requests
 prettytable==3.10.0
diff --git a/packages/seqstat/seqstat.py b/src/cli/seqstat.py
index 55b6ecc..a9d5e64 100755
--- a/packages/seqstat/seqstat.py
+++ b/src/cli/seqstat.py
@@ -1,6 +1,6 @@
 #!/usr/bin/env python3
 
-import argparse
+import click
 
 ticks = ["▁", "▂", "▃", "▄", "▅", "▆", "▇", "█"]
 
@@ -16,15 +16,12 @@ def histogram(sequence):
     return [ticks[int((int(i - min_val) << 8) / scale)] for i in sequence]
 
 
-if __name__ == "__main__":
-    parser = argparse.ArgumentParser()
-    parser.add_argument(
-        "numbers",
-        metavar="N",
-        type=float,
-        nargs="+",
-        help="a number for the accumulator",
-    )
-    args = parser.parse_args()
-    h = histogram(args.numbers)
+@click.command()
+@click.argument('numbers', nargs=-1, type=float)
+def cli(numbers):
+    h = histogram(numbers)
     print("".join(h))
+
+
+if __name__ == "__main__":
+    cli()