Skip to content

rafaelsouzars/Prompito

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

43 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

prompito04

Prompito v1.0.1

Version Status Github Release

Utilitario para desenvolvimento de aplicações CLI.

Notas da versão

  • Correção no nível de acesso da classe Executer.
  • Correção no nome do namespace.

Introdução

O Prompito é uma ferramenta de desenvolvimento para aplicações CLI.

Instalação

Baixe o binário no repositorio clicando aqui

  1. Baixe o binário
https://github.com/rafaelsouzars/prompito/releases

Tutorial

Mapa de argumentos:

./prompito init -r "repo"
Key Value
arg1 init
flag1 -r
arg2 repo

Para iniciar o projeto:

using prompito.Promito;

// Cria um Executer
var app = new Executer();

// Recebe o array de argumentos do app
app.ExecuteCommands(args);

Para iniciar o letreiro com as informações do app:

using prompito.Prompito;

// Cria um Executer
var app = new Executer();

// Ativa o letreito
app.ScreenAbout(true);

// Insere as informações do app
app.InsertData(new {
	AppName = "my-app",
	Version = "v1.0.0",
	Description = "My first app",
	ProfileURL = "https://github.com/<profile>"
	RepositorieURL = "https://github.com/<profile>/<my-app>"
});

// Recebe o array de argumentos do app
app.ExecuteCommands(args);

Criando um ActionCommand:

using prompito.Prompito.Classes;

class <MyActionCommand> : ActionCommand
{
	public override void Run(ArgsMapper argsMapper) 
	{
		// Implementation
	}
}

Adicionando seu ActionCommand:

using prompito.Prompito;
using <myActionCommand-namespace>;

// Inica o executor
var app = new Executer();

// Caso precise apenas utilizar o propio nome do aplicativo como comando
app.AddRootCommand(new MyRootCommand());

// Cria um comando
app.AddCommand("command", "description", new MyActionCommand());

// Recebe os argumentos do console para execução dos comandos
app.ExecuteCommands(args);

Exemplos

// MyRootAction
using prompito.Prompito.Classes;

namespace MyActionCommands
{
	class MyRootActionCommand : ActionCommand 
	{	
		public MyActionCommand()
        {            
            AddFlag(
                "-h",
                "--help",
                "Ajuda do programa"
                );
        }

		public override void Run (ArgsMapper argsMapper) 
		{
			try
            {
                MappedLineTester(argsMapper, "arg1", () => {
                
                    Console.Writeline("Informações do aplicativo");

                });                
                
                MappedLineTester(argsMapper, "arg1 flag1", "flag1=-h", () => {
                
                    Help();
                
                });
                                
               
            }
            catch (Exception exception) 
            {
                Console.WriteLine(" [ ERROR ]\n\t{0}",exception.Message);
            }
		}
	}
}
// MyAction
using prompito.Prompito.Classes;

namespace MyActionCommands
{
	class MyActionCommand : ActionCommand 
	{	
		public MyActionCommand()
        {            
            AddFlag(
                "-r",
                "--repo-hook",
                "Criar hook a partir de repositório de script"                
                );

            AddFlag(
                "-h",
                "--help",
                "Ajuda do comando"
                );
        }

		public override void Run (ArgsMapper argsMapper) 
		{
			try
            {
                MappedLineTester(argsMapper, "arg1", () => {
                
                    Console.WriteLine("Bem vindo ao comando Init"); 

                });
                
                MappedLineTester(argsMapper, "arg1 flag1 arg2", "flag1=-m", () => {
                
                    Console.WriteLine("Mensagem: {0}", argsMapper.GetArgs("arg2"));
                
                }); 
                
                MappedLineTester(argsMapper, "arg1 flag1", "flag1=-h", () => {
                
                    Help();
                
                });
                                
               
            }
            catch (Exception exception) 
            {
                Console.WriteLine(" [ ERROR ]\n\t{0}",exception.Message);
            }
		}
	}
}
// Program.cs
using prompito.Prompito;
using MyActionCommands;

var app = new Executer();

app.ScreenAbout(true);

app.InsertData(new {
	AppName = "my-app",
	Version = "v1.0.0",
	Description = "My first app",
	ProfileURL = "https://github.com/dev"
	RepositorieURL = "https://github.com/dev/my-app"
});

app.AddRootCommand(new MyRootCommand());

app.AddCommand("init", "Inicia um comando", new MyActionCommand());

app.ExecuteCommands(args);