Skip to content

SteGriff/dnformat

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

dnformat

Why

When you're like, "I want this number to have a leading zero but I can't remember how it works" so you look in up in format strings but then you want to test it. So you open a console and type:

$ dnformat "{0:D2}" int:3
03

Yaaay. Now you know.

Usage

For the help text, run

$ dnformat /?

Which displays this:

Usage:
	dnformat format type1:param1,type2:param2...
Examples:
	dnformat "hello {0}" string:world
	dnformat "{0:P} glue" float:0.05
	dnformat "{0:X} {0:X08}" int:37295

The first argument is a format string, like you would pass to String.Format or to Console.WriteLine. It's best to put this in speech marks to group it as one argument. After that, pass your params in the format type:value as shown in examples above.

Note

The software internally allows 'timespan' as a type but it's not really supported because the command line parser splits on ':', which makes it impossible to express a string timespan. This would require a lexical parser for command line input. Please open a pull request to implement one if you feel so inclined! ;)

License

Released into the public domain by means of the UNLICENSE. No rights reserved.

By @SteGriff

About

Console app to test .Net format strings

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages