common: Implement the "ls" shell command.
authorTilman Sauerbeck <tilman@code-monkey.de>
Thu, 9 Jan 2020 22:40:50 +0000 (23:40 +0100)
committerTilman Sauerbeck <tilman@code-monkey.de>
Sat, 11 Jan 2020 09:15:46 +0000 (10:15 +0100)
Shows a listing of the stored recordings.

src/common/shell.rs

index 59472f6c9eb029d5e4aa6c70649586fa2a7f379c..097bd0cf8d7e5b9cd8b85134aadf4bbe50cc1cb3 100644 (file)
@@ -197,6 +197,7 @@ impl<'a> Shell<'a> {
                 let usage = b"\
 Supported commands:
     help           Show this help message.
+    ls             List recordings.
     get REC_ID     Retrieve recording.
     clear_storage  Fully erase the flash's contents.
     dump_storage   Dump the flash's contents.
@@ -205,6 +206,7 @@ Supported commands:
                 self.tx_buf.write(usage);
             },
 
+            Some(b"ls") => self.run_ls(logger),
             Some(b"get") => self.run_get(logger, &mut args_iter),
             Some(b"clear_storage") => self.run_clear_storage(logger),
             Some(b"dump_storage") => self.run_dump_storage(logger),
@@ -220,6 +222,10 @@ Supported commands:
         }
     }
 
+    fn run_ls(&mut self, logger: &mut Logger) {
+        logger.list_recordings(self.tx_buf);
+    }
+
     fn run_get(&mut self, logger: &mut Logger, args_iter: &mut ArgumentIter) {
         if let Some(recording_id_s) = args_iter.next() {
             if let Some(recording_id) = atoi16(recording_id_s) {