]> git.rocketbowman.com Git - nom.git/commitdiff
feat: display header with nom * show
authorKyle Bowman <kyle+github@rocketbowman.com>
Sat, 25 Jan 2025 19:54:18 +0000 (14:54 -0500)
committerKyle Bowman <kyle+github@rocketbowman.com>
Sat, 25 Jan 2025 19:54:18 +0000 (14:54 -0500)
src/nom/base.py
src/nom/main.py

index 5cd0591741a739f5ce8022b19e6fe59f5b6cc492..3ed198e4895f49fa45a872647474a9fbf0c208d4 100644 (file)
@@ -65,7 +65,7 @@ class NomList(set):
     
     def to_stdout(self):
         for item in self.items:
-            print(item.to_str(delimeter="\t"))
+            print(item.to_str(delimiter="\t"))
 
     @classmethod
     def from_csv(cls, file: Path, delimiter="|"):
@@ -94,9 +94,12 @@ class NomList(set):
             for item in self:
                 writer.writerow(item.to_dict())
     
-    def to_stdout(self):
+    def to_stdout(self, show_header=False, delimiter="|"):
         if not self:
             raise NomError("There are no entries to write.")
+        if show_header:
+            headers = next(iter(self)).get_fieldnames()
+            print(delimiter.join(headers))
         for item in self:
             print(item.to_str())
     
\ No newline at end of file
index 2b55385f00fc2550f9756f019792905eda094c23..c1d55350693bdb900d3e389e52c9628a56f38607 100644 (file)
@@ -44,12 +44,12 @@ def main(args=['nom'].append(sys.argv)):
         elist.to_csv(ENTRY_LIST)
     elif args.command == "entry" and args.entry_command == "show":
         elist = EntryList.from_csv(ENTRY_LIST)
-        elist.to_stdout()
+        elist.to_stdout(show_header=True)
     elif args.command == "feed" and args.feed_command == "update":
         feedlist.update_labels()
         feedlist.fetch_feeds(FEED_CACHE)
     elif args.command == "feed" and args.feed_command == "show":
-        feedlist.to_stdout()
+        feedlist.to_stdout(show_header=True)
     else:
         raise NomError("That option is not yet supported.")