summaryrefslogtreecommitdiff
path: root/apply/status.py
diff options
context:
space:
mode:
authorJulian T <julian@jtle.dk>2021-04-24 20:28:44 +0200
committerJulian T <julian@jtle.dk>2021-04-24 20:32:37 +0200
commit0c24ead1cb0126a1847c2ed971649e9ee25e920e (patch)
tree20a9e5e791b72696f3784fa4580530a5f3d16810 /apply/status.py
parent62d63afb0783b42f9f6bdbecc81b701b9d629093 (diff)
Add status subcommand
Diffstat (limited to 'apply/status.py')
-rw-r--r--apply/status.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/apply/status.py b/apply/status.py
new file mode 100644
index 0000000..514252b
--- /dev/null
+++ b/apply/status.py
@@ -0,0 +1,24 @@
+import argparse
+from .state import StateFile, FileState
+from pathlib import Path
+from tabulate import tabulate
+
+
+def cmd_args(_: argparse.ArgumentParser):
+ pass
+
+
+def cmd_func(args, config):
+ state = StateFile(args.apply_dir)
+ rows = []
+ for link in state.links:
+ st = FileState.check_location(Path(link))
+ rows.append((link, st.check_string(Path.cwd())))
+
+ print(tabulate(rows, headers=["Link", "Status"]), "\n")
+
+ rows = state.dirs.items()
+ print(tabulate(rows, headers=["Directory", "Owned by"]))
+
+
+cmd_help = "Check status on owned links"