Organize commands
This commit is contained in:
parent
421d6d2907
commit
032c7c6339
1 changed files with 26 additions and 11 deletions
|
@ -37,6 +37,9 @@ while (line = $stdin.gets)
|
||||||
begin
|
begin
|
||||||
command, rest = parse_command line
|
command, rest = parse_command line
|
||||||
case command
|
case command
|
||||||
|
##################
|
||||||
|
# Administrative #
|
||||||
|
##################
|
||||||
when 'EXIT'
|
when 'EXIT'
|
||||||
success
|
success
|
||||||
exit
|
exit
|
||||||
|
@ -45,6 +48,13 @@ while (line = $stdin.gets)
|
||||||
when 'STACKTRACE'
|
when 'STACKTRACE'
|
||||||
success stacktrace
|
success stacktrace
|
||||||
stacktrace = nil
|
stacktrace = nil
|
||||||
|
##########
|
||||||
|
# Config #
|
||||||
|
##########
|
||||||
|
when 'REGISTER_CATEGORY'
|
||||||
|
data = JSON.parse rest
|
||||||
|
config.categories.register String(data).to_sym
|
||||||
|
success
|
||||||
when 'REGISTER_FORMAT'
|
when 'REGISTER_FORMAT'
|
||||||
data = JSON.parse rest
|
data = JSON.parse rest
|
||||||
config.formats.register(
|
config.formats.register(
|
||||||
|
@ -52,21 +62,13 @@ while (line = $stdin.gets)
|
||||||
**data.except('name').transform_keys(&:to_sym),
|
**data.except('name').transform_keys(&:to_sym),
|
||||||
)
|
)
|
||||||
success
|
success
|
||||||
when 'REGISTER_CATEGORY'
|
|
||||||
data = JSON.parse rest
|
|
||||||
config.categories.register String(data).to_sym
|
|
||||||
success
|
|
||||||
when 'REGISTER_REF'
|
when 'REGISTER_REF'
|
||||||
data = JSON.parse rest
|
data = JSON.parse rest
|
||||||
config.repo.register_ref(**data.transform_keys(&:to_sym))
|
config.repo.register_ref(**data.transform_keys(&:to_sym))
|
||||||
success
|
success
|
||||||
when 'MAKE_REF'
|
########
|
||||||
config.freeze
|
# Info #
|
||||||
data = JSON.parse rest
|
########
|
||||||
success footnotes.make_ref(
|
|
||||||
String(data['category']).to_sym,
|
|
||||||
String(data['id']),
|
|
||||||
).to_h
|
|
||||||
when 'REF'
|
when 'REF'
|
||||||
config.freeze
|
config.freeze
|
||||||
data = JSON.parse rest
|
data = JSON.parse rest
|
||||||
|
@ -74,6 +76,19 @@ while (line = $stdin.gets)
|
||||||
String(data['category']).to_sym,
|
String(data['category']).to_sym,
|
||||||
String(data['id']),
|
String(data['id']),
|
||||||
].to_h
|
].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'
|
when 'FETCH_NOTE'
|
||||||
config.freeze
|
config.freeze
|
||||||
data = JSON.parse rest
|
data = JSON.parse rest
|
||||||
|
|
Loading…
Reference in a new issue