-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refatorando as opções de command line #2
base: master
Are you sure you want to change the base?
Conversation
.idea/ | ||
cotuba-cli.iml | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Boa!
|
||
import org.apache.commons.cli.*; | ||
|
||
public class OptionCLIReader { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
O projeto já estava usando as variáveis em português. Por isso, acho que seria melhor manter o nome da classe em português.
Options options = new Options(); | ||
|
||
options.addOption(new Option("d", "dir", true, "Diretório que contem os arquivos md. Default: diretório atual.")); | ||
options.addOption(new Option("f", "format", true, "Formato de saída do ebook. Pode ser: pdf ou epub. Default: pdf")); | ||
options.addOption(new Option("o", "output", true, "Arquivo de saída do ebook. Default: book.{formato}.")); | ||
options.addOption(new Option("v", "verbose", false, "Habilita modo verboso.")); | ||
|
||
CommandLineParser cmdParser = new DefaultParser(); | ||
HelpFormatter ajuda = new HelpFormatter(); | ||
CommandLine cmd; | ||
|
||
try { | ||
cmd = cmdParser.parse(options, args); | ||
} catch (ParseException e) { | ||
System.err.println(e.getMessage()); | ||
ajuda.printHelp("cotuba", options); | ||
System.exit(1); | ||
return; | ||
} | ||
|
||
this.nomeDoDiretorioDosMD = cmd.getOptionValue("dir"); | ||
this.nomeDoFormatoDoEbook = cmd.getOptionValue("format"); | ||
this.nomeDoArquivoDeSaidaDoEbook = cmd.getOptionValue("output"); | ||
this.modoVerboso = cmd.hasOption("verbose"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Você acha que seria bom reorganizar esse trecho de código? Se sim, como você faria?
No description provided.