Organize commands

This commit is contained in:
Alex Kotov 2023-09-30 18:38:55 +04:00
parent 421d6d2907
commit 032c7c6339
Signed by: kotovalexarian
GPG Key ID: 553C0EBBEB5D5F08
1 changed files with 26 additions and 11 deletions

View File

@ -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