Click here to Skip to main content
15,886,422 members

The Weird and The Wonderful

   

The Weird and The Wonderful forum is a place to post Coding Horrors, Worst Practices, and the occasional flash of brilliance.

We all come across code that simply boggles the mind. Lazy kludges, embarrassing mistakes, horrid workarounds and developers just not quite getting it. And then somedays we come across - or write - the truly sublime.

Post your Best, your worst, and your most interesting. But please - no programming questions . This forum is purely for amusement and discussions on code snippets. All actual programming questions will be removed.

 
GeneralRe: Interesting Observation Pin
Pablo Aliskevicius29-Apr-13 19:47
Pablo Aliskevicius29-Apr-13 19:47 
GeneralRe: Interesting Observation Pin
agolddog1-May-13 3:42
agolddog1-May-13 3:42 
GeneralRe: Interesting Observation Pin
Raja Sekhar S5-Jun-13 21:14
Raja Sekhar S5-Jun-13 21:14 
GeneralRe: Interesting Observation Pin
Pablo Aliskevicius5-Jun-13 21:21
Pablo Aliskevicius5-Jun-13 21:21 
GeneralRe: Interesting Observation Pin
Raja Sekhar S5-Jun-13 22:05
Raja Sekhar S5-Jun-13 22:05 
GeneralRe: Interesting Observation Pin
Pablo Aliskevicius5-Jun-13 23:31
Pablo Aliskevicius5-Jun-13 23:31 
GeneralRe: Interesting Observation Pin
Raja Sekhar S5-Jun-13 23:39
Raja Sekhar S5-Jun-13 23:39 
GeneralNot 'Clap' but 'CLAP', dammit. Pin
Brady Kelly24-Apr-13 22:36
Brady Kelly24-Apr-13 22:36 
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:

C#
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.

GeneralRe: Not 'Clap' but 'CLAP', dammit. Pin
dusty_dex24-Apr-13 23:19
dusty_dex24-Apr-13 23:19 
GeneralRe: Not 'Clap' but 'CLAP', dammit. Pin
Brady Kelly24-Apr-13 23:33
Brady Kelly24-Apr-13 23:33 
GeneralRe: Not 'Clap' but 'CLAP', dammit. Pin
H.Brydon25-Apr-13 14:59
professionalH.Brydon25-Apr-13 14:59 
GeneralRe: Not 'Clap' but 'CLAP', dammit. Pin
Brisingr Aerowing25-Apr-13 1:16
professionalBrisingr Aerowing25-Apr-13 1:16 
GeneralRe: Not 'Clap' but 'CLAP', dammit. Pin
Brady Kelly25-Apr-13 2:56
Brady Kelly25-Apr-13 2:56 
GeneralRe: Not 'Clap' but 'CLAP', dammit. Pin
hvanzyll26-Apr-13 5:26
hvanzyll26-Apr-13 5:26 
GeneralRe: Not 'Clap' but 'CLAP', dammit. Pin
Rob Grainger1-May-13 3:23
Rob Grainger1-May-13 3:23 
GeneralProduction code adds a BCC to email account of developer Pin
0bx24-Apr-13 5:48
0bx24-Apr-13 5:48 
AnswerRe: Production code adds a BCC to email account of developer Pin
AspDotNetDev24-Apr-13 5:54
protectorAspDotNetDev24-Apr-13 5:54 
GeneralRe: Production code adds a BCC to email account of developer Pin
BillW3325-Apr-13 9:17
professionalBillW3325-Apr-13 9:17 
GeneralRe: Production code adds a BCC to email account of developer Pin
AspDotNetDev25-Apr-13 9:20
protectorAspDotNetDev25-Apr-13 9:20 
GeneralRe: Production code adds a BCC to email account of developer Pin
agolddog26-Apr-13 3:41
agolddog26-Apr-13 3:41 
GeneralRe: Production code adds a BCC to email account of developer Pin
Bernhard Hiller25-Apr-13 3:54
Bernhard Hiller25-Apr-13 3:54 
GeneralRe: Production code adds a BCC to email account of developer Pin
RafagaX26-Apr-13 4:42
professionalRafagaX26-Apr-13 4:42 
GeneralNested if-else statements... Pin
Thomas Daniels23-Apr-13 7:21
mentorThomas Daniels23-Apr-13 7:21 
GeneralRe: Nested if-else statements... Pin
Akinmade Bond23-Apr-13 7:49
professionalAkinmade Bond23-Apr-13 7:49 
GeneralRe: Nested if-else statements... Pin
OriginalGriff23-Apr-13 8:12
mveOriginalGriff23-Apr-13 8:12 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.