Skip to content

Commit

Permalink
Removed options that accept glossary_id
Browse files Browse the repository at this point in the history
  • Loading branch information
kojix2 committed Apr 10, 2024
1 parent 32962f1 commit 8fe5e88
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 37 deletions.
40 changes: 12 additions & 28 deletions src/deepl/cli.cr
Original file line number Diff line number Diff line change
Expand Up @@ -84,17 +84,14 @@ module DeepL

result = nil
translator = DeepL::Translator.new
if option.glossary_name
option.glossary_id = translator.convert_glossary_name_to_id(option.glossary_name.not_nil!)
end

with_spinner do
result = translator.translate_text(
text: option.input_text,
target_lang: option.target_lang,
source_lang: option.source_lang,
formality: option.formality,
glossary_id: option.glossary_id,
glossary_name: option.glossary_name, # original option of deepl.cr
context: option.context
)
end
Expand All @@ -121,17 +118,14 @@ module DeepL
end

translator = DeepL::Translator.new
if option.glossary_name
option.glossary_id = translator.convert_glossary_name_to_id(option.glossary_name.not_nil!)
end

with_spinner do
translator.translate_document(
path: option.input_path,
target_lang: option.target_lang,
source_lang: option.source_lang,
formality: option.formality,
glossary_id: option.glossary_id,
glossary_name: option.glossary_name, # original option of deepl.cr
output_format: option.output_format,
output_file: option.output_file,
interval: option.interval
Expand Down Expand Up @@ -187,33 +181,23 @@ module DeepL

def delete_glossary
translator = DeepL::Translator.new
glossary_id = option.glossary_id
if glossary_id
translator.delete_glossary(glossary_id)
if ARGV.size == 0
print_help
exit(1)
else
if ARGV.size == 0
print_help
exit(1)
else
glossary_name = ARGV[0]
translator.delete_glossary_by_name(glossary_name)
end
glossary_name = ARGV[0]
translator.delete_glossary_by_name(glossary_name)
end
end

def output_glossary_entries
translator = DeepL::Translator.new
glossary_id = option.glossary_id
if glossary_id
puts translator.get_glossary_entries(glossary_id)
if ARGV.size == 0
print_help
exit(1)
else
if ARGV.size == 0
print_help
exit(1)
else
glossary_name = ARGV[0]
puts translator.get_glossary_entries_by_name(glossary_name)
end
glossary_name = ARGV[0]
puts translator.get_glossary_entries_by_name(glossary_name)
end
end

Expand Down
2 changes: 1 addition & 1 deletion src/deepl/options.cr
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ module DeepL
property source_lang : String? = nil
property detect_source_lanuage : Bool = false
property formality : String? = nil
property glossary_id : String? = nil
# property glossary_id : String? = nil
property glossary_name : String? = nil
property context : String? = nil
property split_sentences : String? = nil
Expand Down
16 changes: 8 additions & 8 deletions src/deepl/parser.cr
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ module DeepL
opt.target_lang = to.upcase
end

on("-g", "--glossary NAME", "Glossary name") do |id|
opt.glossary_id = id
on("-g", "--glossary NAME", "Glossary name") do |name|
opt.glossary_name = name
end

on("-F", "--formality OPT", "Formality (default more less)") do |v|
Expand Down Expand Up @@ -117,9 +117,9 @@ module DeepL
on("delete", "Delete a glossary") do
_set_action_(Action::DeleteGlossary, "Usage: deepl glossary delete <name>")

on("-i", "--id ID", "View glossary by Glossary ID") do |id|
opt.glossary_id = id
end
# on("-i", "--id ID", "View glossary by Glossary ID") do |id|
# opt.glossary_id = id
# end

_on_debug_

Expand All @@ -129,9 +129,9 @@ module DeepL
on("view", "View a glossary") do
_set_action_(Action::OutputGlossaryEntries, "Usage: deepl glossary view <name>")

on("-i", "--id ID", "Delete glossary by Glossary ID") do |id|
opt.glossary_id = id
end
# on("-i", "--id ID", "Delete glossary by Glossary ID") do |id|
# opt.glossary_id = id
# end

_on_debug_

Expand Down

0 comments on commit 8fe5e88

Please sign in to comment.