From 488a97f3f67ed29ed18af6ac84dccba033e0a111 Mon Sep 17 00:00:00 2001 From: Jan Bertram Date: Wed, 8 Nov 2023 12:09:07 +0100 Subject: [PATCH] Feature added: `sp piece_number` shows movements --- README.md | 2 +- rep_cli.py | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index dc9cb9d..b95d256 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ At the moment, an alpha version is undertaken, with these features: - Show the pieces stored in the database (`s`) - Mark pieces as mastered for the active user (`m number_of_work`) - Show pieces by composer (`sc` shows composers, `c number_of_composer` shows pieces) -- (planned) Show movements through pieces +- Show movements through pieces (`sp piece_number`) - (planned) Mark movement as mastered for active user - (planned) Save recordings per movement in db - (planned) Listen to saved recordings diff --git a/rep_cli.py b/rep_cli.py index ee0dd84..b02d393 100644 --- a/rep_cli.py +++ b/rep_cli.py @@ -40,6 +40,8 @@ class Session: self.resultstring += self.show_works() elif command == 'sc': self.resultstring += self.show_works(restraint=f'comp_id = {arguments[0]}') + elif command == 'sp': + self.resultstring += self.show_movements(arguments[0]) elif command == 'su': self.resultstring += self.show_users() elif command == 'q': @@ -69,6 +71,13 @@ class Session: fun_resultstring += f'{item[0]}: {item[2]}, {item[1]}\n' return fun_resultstring + def show_movements(self, work_id): + work = work_under_id(work_id, self.db_agent) + fun_resultstring = '' + for mov_number in work.values['movements'].keys(): + fun_resultstring += f'{mov_number}. {work.pretty_mov(mov_number)}\n' + return fun_resultstring + def show_users(self): sql_command = ''' SELECT * FROM pianist; @@ -220,7 +229,7 @@ class work_under_id: def parse_user_input(user_in): split_user_in = user_in.split() command = split_user_in[0] - if command in ('a', 'c', 'm', 'n', 'q', 's', 'sc', 'su'): + if command in ('a', 'c', 'm', 'n', 'q', 's', 'sc', 'sp', 'su'): arguments = split_user_in[1:] return (command, arguments) else: