Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

CassioMasteguim
Copy link

No description provided.

Comment on lines +8 to +10
.idea/
cotuba-cli.iml

Copy link
Contributor

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 {
Copy link
Contributor

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.

Comment on lines +13 to +36
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");
Copy link
Contributor

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants