Skip to content

KsWare/KsWare.CmdDotNet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

KsWare.CmdDotNet

Library for Console projets

  • .Net methods for known console commands
    • echo, prompt, pause, ...
    • mklink, robocopy, ...
  • strongly typed command line args (CommandLineArgs class, with CommandLineSwitchAttributes)

.Net Methods for known console commands

  • Echo, Get, Set, Start, PopD, PushD, Pause
  • PauseIf, Prompt
  • MkLink, Robocopy

Echo(string text, TextWriter? redirect=null)

// echo Hello World
Echo("Hello World")

// echo Hello World>>foo.txt
Echo("Hello World", ToFile("foo.txt", append:true))

Set(string environmentVariable, string value)

// set GREETINGS=Hello World
Set("GREETINGS", "Hello World")

// set /p GREETINGS=Ask Question?
Set("GREETINGS", Prompt("Ask Question?"))

Strongly typed command line args

Using CommandLineArgsBase includes the parser.

public CommandLineArgs : CommandLineArgsBase {

    [CommandLineSwitch("-?","/?","--help")]
    public bool IsHelp { get; set; }

    [CommandLineSwitch("-n", Desription="A number")]
    public int Number { get; set; }

    [CommandLineSwitch("-b", Description="A bool value")]
    public bool MyBool { get; set; }

    [CommandLineSwitch("-o", Parameter="[<file-name>]", Desription="Optional value")]
    public string Output { get; set; }
}

Auto generated help text:

Options:
  -? /? --help      This help
  -n <number>       A number
  -b                A bool value
  -o [<file-name>]  Optional value

About

Cmd like commands für .Net console projects

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages