|
I'm trying out various command line option parser libraries, and those with verb or command options are few and far between. CLAP[^] is one that handles verbs, e.g. I don't need a separate Console application for each task, where the CLI library just parses the options for that command. I want a library where I can have one Console app, which accepts a command/verb and the options for that verb get parsed. So far I've found only CLAP and ManyConsole[^].
E.g. I don't want to have to have import.exe filename [-repeat] but I want console.exe import filename [-repeat] .
So I built a console application called Clap, with this code:
using System;
using CLAP;
namespace Clap
{
class Program
{
static void Main(string[] args)
{
Parser.Run<Program>(args);
}
[Verb(Description = "Imports an Impro CSV report file.", Aliases = "import,imp")]
static void ImportCsv(
[Required]
[Description("Full path to the file to import.")] string filePath)
{
Console.WriteLine("Will import " + filePath);
}
}
}
When I run the application with clap /? or clap import xxx , I get the error message
Unhandled Exception: System.TypeLoadException: Could not load type 'CLAP.Parser' from assembly 'Clap, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.
at Clap.Program.Main(String[] args)
Google provided zero leads, so the problem was not well known. Well, how well known is CLAP itself? The Version-=1.0.0.0 gave me the key clue. It looked like the app was trying to load CLAP.Parser from my Clap assembly, not the CLAP library assembly, which is version 4.3.
All it took was to change my assembly name and default namespace to ClapCli and the problem vanished, but just BTW, CLAP is very, very thin. It throws exceptions when verbs arguments are omitted, and expects you to decorate a method to do something with the exception. It also has no built in help provider, and requires you to decorate a method that is called when the user requests help. You must compose and format your own help text for every verb and option.
modified 25-Apr-13 5:32am.
|
|
|
|
|
If you look at one of the examples you'll find this:
using CLAP;
using CLAP.Validation;
class ClapApp
{
.
.
.
}
> "Well, how well known is CLAP itself? "
"It's true that hard work never killed anyone. But I figure, why take the chance." - Ronald Reagan
That's what machines are for.
Got a problem?
Sleep on it.
modified 25-Apr-13 5:27am.
|
|
|
|
|
I just changed my app name from 'Clap' to 'ClapCli' and it was fixed. See the last paragraph, that I've just added.
|
|
|
|
|
Your code is like a dose of clap. Errr no, Clap. No, CLAP!
--
Harvey
|
|
|
|
|
How's this one[^]?
It handles verbs as well, and allows you to not use them as well.
Gryphons Are Awesome! Gryphons Are Awesome!
|
|
|
|
|
That ended up my second choice, but ManyConsole won, with better automatic help for available verbs and their options.
|
|
|
|
|
I think you need a virus checker on that...
your code has the clap.
|
|
|
|
|
Not to be pedantic, but I think you'll find the clap is a bacterial infection.
(Just don't ask how I became an expert )
|
|
|
|
|
No idea why he was "spying" on a client.
We only found this out after he left and we took over the account.
private MailMessage BuildMailMessage(...)
{
...
mailMessage.BCC.Add("guys@address.com");
..
}
.
|
|
|
|
|
Some of us have done that at my job to temporarily monitor production emails to be sure everything is working as expected.
|
|
|
|
|
I can understand why a dev would want to monitor things to ensure that everything is working properly. I also understand why a customer would not like the idea of being spied upon.
Just because the code works, it doesn't mean that it is good code.
|
|
|
|
|
Potayto, potawto.
Another thing we do is retain any emails sent from our servers. I suppose that could be considered spying too.
|
|
|
|
|
AspDotNetDev wrote: Some of us have done that at my job to temporarily monitor production emails to
be sure everything is working as expected.
Yeah, that would be my initial reaction too. Just making sure the body/to/ccs/etc are working right. Of course, I'm coming from my world, where we have several automatically-generated emails. Although I would typically write this info to a log instead of copying myself/someone else.
A little disappointing that dev didn't configure the 'emailChecker' address so it could be easily de-configured.
|
|
|
|
|
Somewhere (the daily WTF?) I saw <a href="mailto:....bcc=guys@address.com.."> link. Seems to be not so uncommon.
|
|
|
|
|
Thinking the best, he wanted to be sure that the system was running perfectly, thinking the worst, he may be working for someone else... However, if the account was a corporate account (and not his personal email account), most likely he was monitoring the system.
|
|
|
|
|
I found this in one of my old codes (it was a program to check whether a square was a magic square[^] or not)
private void button1_Click(object sender, EventArgs e)
{
int lefttop = Convert.ToInt16(_1.Text);
int centertop = Convert.ToInt16(_2.Text);
int righttop = Convert.ToInt16(_3.Text);
int leftcenter = Convert.ToInt16(_4.Text);
int centercenter = Convert.ToInt16(_5.Text);
int rightcenter = Convert.ToInt16(_6.Text);
int leftbottom = Convert.ToInt16(_7.Text);
int centerbottom = Convert.ToInt16(_8.Text);
int rightbottom = Convert.ToInt16(_9.Text);
int row1 = lefttop + centertop + righttop;
int row2 = leftcenter + centercenter + rightcenter;
int row3 = leftbottom + centerbottom + rightbottom;
int col1 = lefttop + leftcenter + leftbottom;
int col2 = centertop + centercenter + centerbottom;
int col3 = righttop + rightcenter + rightbottom;
int dia1 = lefttop + centercenter + rightbottom;
int dia2 = leftbottom + centercenter + righttop;
if (row1 == row2)
{
if (row2 == row3)
{
if (row3 == col1)
{
if (col1 == col2)
{
if (col2 == col3)
{
if (col3 == dia1)
{
if (dia1 == dia2)
{
MessageBox.Show("Your magic square is correct!");
}
else
{
MessageBox.Show("Wrong! Application will restart!");
this.Close();
Process restart = new Process();
restart.StartInfo.FileName = @"path name here";
restart.Start();
}
}
else
{
MessageBox.Show("Wrong! Application will restart!");
this.Close();
Process restart = new Process();
restart.StartInfo.FileName = @"path name here";
restart.Start();
}
}
else
{
MessageBox.Show("Wrong! Application will restart!");
this.Close();
Process restart = new Process();
restart.StartInfo.FileName = @"path name here";
restart.Start();
}
}
else
{
MessageBox.Show("Wrong! Application will restart!");
this.Close();
Process restart = new Process();
restart.StartInfo.FileName = @"path name here";
restart.Start();
}
}
else
{
MessageBox.Show("Wrong! Application will restart!");
this.Close();
Process restart = new Process();
restart.StartInfo.FileName = @"path name here";
restart.Start();
}
}
else
{
MessageBox.Show("Wrong! Application will restart!");
this.Close();
Process restart = new Process();
restart.StartInfo.FileName = @"path name here";
restart.Start();
}
}
else
{
MessageBox.Show("Wrong! Application will restart!");
this.Close();
Process restart = new Process();
restart.StartInfo.FileName = @"path name here";
restart.Start();
}
}
|
|
|
|
|
lol
The first step in the acquisition of wisdom is silence, the second is listening, the third memory, the forth, practice and the fifth is teaching others!
|
|
|
|
|
Well...at least you indented it correctly?
But that's terrible! You still use Visual Studio default names for your controls?
The universe is composed of electrons, neutrons, protons and......morons. (ThePhantomUpvoter)
|
|
|
|
|
Ah... the glorious joy of "WTF"
(yes|no|maybe)*
|
|
|
|
|
Looks like you get payed by lines of code
|
|
|
|
|
I don´t believe in if anymore
|
|
|
|
|
Quote: I don´t believe in if anymore It's not "if", it's "when." You have to think positive.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
You're right!
But, don`t just disregard this code, even Metallica says "nothing ELSE matters"
So, try coding ELSE without the IF.
|
|
|
|
|
How about SOMETHING ELSE?
"It's true that hard work never killed anyone. But I figure, why take the chance." - Ronald Reagan
That's what machines are for.
Got a problem?
Sleep on it.
|
|
|
|
|
Wonderfull! Even to the point of paraphrasing the old BASIC error message "?Redo from start" - and so that we really can see it, duplicate it several times.
Nice
|
|
|
|