From 032c7c63394eae0aecab14937717c0450580583c Mon Sep 17 00:00:00 2001 From: Alex Kotov Date: Sat, 30 Sep 2023 18:38:55 +0400 Subject: [PATCH] Organize commands --- exe/referator | 37 ++++++++++++++++++++++++++----------- 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/exe/referator b/exe/referator index f99c522..2552cf8 100755 --- a/exe/referator +++ b/exe/referator @@ -37,6 +37,9 @@ while (line = $stdin.gets) begin command, rest = parse_command line case command + ################## + # Administrative # + ################## when 'EXIT' success exit @@ -45,6 +48,13 @@ while (line = $stdin.gets) when 'STACKTRACE' success stacktrace stacktrace = nil + ########## + # Config # + ########## + when 'REGISTER_CATEGORY' + data = JSON.parse rest + config.categories.register String(data).to_sym + success when 'REGISTER_FORMAT' data = JSON.parse rest config.formats.register( @@ -52,21 +62,13 @@ while (line = $stdin.gets) **data.except('name').transform_keys(&:to_sym), ) success - when 'REGISTER_CATEGORY' - data = JSON.parse rest - config.categories.register String(data).to_sym - success when 'REGISTER_REF' data = JSON.parse rest config.repo.register_ref(**data.transform_keys(&:to_sym)) success - when 'MAKE_REF' - config.freeze - data = JSON.parse rest - success footnotes.make_ref( - String(data['category']).to_sym, - String(data['id']), - ).to_h + ######## + # Info # + ######## when 'REF' config.freeze data = JSON.parse rest @@ -74,6 +76,19 @@ while (line = $stdin.gets) String(data['category']).to_sym, String(data['id']), ].to_h + ############ + # Creation # + ############ + when 'MAKE_REF' + config.freeze + data = JSON.parse rest + success footnotes.make_ref( + String(data['category']).to_sym, + String(data['id']), + ).to_h + ############# + # Rendering # + ############# when 'FETCH_NOTE' config.freeze data = JSON.parse rest