Skip to content
Oskar Gewalli edited this page Oct 13, 2019 · 5 revisions

Isop

Intro: Overview

What kind of problem does this lib solve?

Mostly it’s intended to reduce the amount of code needed to create command line applications. It’s also intended to give structure to your command line application (to simplify the reuse of your code).

Goal

The goal is to be able to write code like:

someprogram.exe My Action --argument value

So that the class with the name My or MyController and the method with the name Action gets invoked.

Description

This library is intended to be like chocolate pudding mix. Not something that will replace your dinner, but rather something easy to make for dessert. A way of helping you build for instance the essential administrative apps. It’s not a replacement for baking cake (building a full blown administrative interface in html, silverlight, wpf).

How to use?

Having your own Main

You’re hooking it up by writing something like:

static async Task<int> Main(string[] args)
{
    var appHost = AppHostBuilder
        .Create(new Configuration
        {
            CultureInfo = CultureInfo.InvariantCulture
        })
        .Recognize(typeof(MyController))
        .Recognize(typeof(CustomerController))
        .BuildAppHost();
    return await appHost.Parse(args).TryInvokeAsync();
}

Look at the Example project for the most recent example of how it is used.

Also look at the usage section of the wiki.

Contrib: How to change?

Reading the code: Start by browsing the tests

Run the tests. Do they fail? Hopefully not. Read what the test promise that the code is supposed to do.

Changing the code: Add tests

It’s missing something? Add another test. It should be red (since the functionality is missing). Change the code so that the tests pass. Refactor the code so that it’s easier to read. Run the tests…

Bugs?

Use github issue tracker . This project is an open source project. That means that you cant expect anyone to fix your problems (they might do it anyway).

If youre using a project and you have problem with bugs:

  • Add issue to issue tracker
    • If it’s an active project, you might get quick response.
  • Fork it
    • If you’ve done something small that fixes the issue, send a pull request with a comment about how it fixes the issue.

The code and the structure of the code

  • Fluent interface A thin layer on top of the object model
    (uses) →
    • Controller recognizers Responsible for setting up the parsing and recognizing of controller input
    • Argument with options Responsible for parsing global style parameters
      (uses) →
      • Parser
      • Lexer

Note that the fluent api is supposed to be a relatively thin layer on the model. This is to have a nice abstraction to write tests against.

Many of the components in this lib are heavy users of reflection. This is to enable a sort of duck type experience (and have a very loose coupling of your code to isop). The library will also try to read the xml documentation to display better help. Instead of using our own attributes, we use the data annotations Required attribute .