NeelBook 1.0.2

dotnet tool install --global NeelBook --version 1.0.2
This package contains a .NET tool you can call from the shell/command line.
dotnet new tool-manifest # if you are setting up this repo
dotnet tool install --local NeelBook --version 1.0.2
This package contains a .NET tool you can call from the shell/command line.
#tool dotnet:?package=NeelBook&version=1.0.2
nuke :add-package NeelBook --version 1.0.2

NeelBook

NeelBook is a CLI tool to generate code based on configuration in json format, for all programing languages

Commands

To view all available commands:

neelbook

To create a new project

neelbook new [name]

To view all available plugins (plugins are templates)

neelbook plugin list

To add remove plugins :

neelbook plugin add [name]
neelbook plugin remove [name]

To execute code generation using templates:

neelbook run

Creating/Updating templates

Basic Syntax

We have three kinds of contents:

  1. Normal text: this is the text will be printed to the outout documents without any processing
  2. Line statements: These are lines start with the code //##
  3. Inline statements: These are code between ((## and ##)) the code between them will be evaluated and printed automatically for example:
Normal text
//## LINE STATEMENT
Normal text ((## INLINE STATEMENT ##)) Normal text 
Normal text

Define Variable

You can define string, integers and json content formats like the following:

//## str myStringVar = "Hello world"
//## int myInteger = 5
//## json myJsonConfig = "./metadata.json"

When you declare json, the system will load its content to this variable

Assign Value to Variable

This is similar to declaration but no need to the variable type keyword:

//## myStringVar = "Hello world"
//## myInteger = 5
//## myJsonConfig = "./metadata.json"

You can also append value to string and integer variables:

//## myStringVar += " my dear"
//## myInteger = 3

To print out variables in the templates you can use print statement:

//## print myInteger
//## print myStringVar

You can add remarks to any statements using the keyword rem, so it will not be executed.

//## rem THIS WILL BE IGNORED

Controlling flow

You can use if statement as following:

//## if myInteger = 5
//## rem BEFORE END YOU CAN PUT IF BODY
//## end

//## if myInteger >= 5
//## rem BEFORE END YOU CAN PUT IF BODY
//## end

//## if myInteger <> 5
//## rem BEFORE END YOU CAN PUT IF BODY
//## end

//## if myStringVar = "Text goes here"
//## rem BEFORE END YOU CAN PUT IF BODY
//## end

You can use for statement as following:

//## for counter = 5
//## rem This will be executed 5 times
//## end

The starting value is one and the last value was speficied in the for declaration

You can access array in the json file and create loops using them like the following:

//## json myJsonFileContent = './myJsonFile.json'
//## foreach item = myJsonFileContent.array
//## rem Foreach body
//## end

Please not you can access sub array of other json elements like this:

//## json myJson = './myJsonFile.json'
//## foreach item = myJson.section1.subSection1.array
//## rem Foreach body
//## end

String Functions

let's define a string variable called x1 equals to "AppLibTest" and use string functions aginst it:

Command Result
x1 AppLibTest
camel(x1) appLibTest
pascal(x1) AppLibTest
snake(x1) applibtest
kebab(x1) applibtest
spacer(x1) App Lib Test
hyphen(x1) app-lib-test
lower(x1) applibtest
upper(x1) APPLIBTEST
replace(hyphen(x1) "-" "/") app/lib/test

let's define another string variable called y1 equals to "Book Library" and use string functions aginst it:

Command Result
y1 Book Library
camel(y1) bookLibrary
pascal(y1) BookLibrary
snake(y1) book_library
kebab(y1) book-library
spacer(y1) Book Library
hyphen(y1) book -library
lower(y1) book library
upper(y1) BOOK LIBRARY
replace(hyphen(y1) "-" "/") book /library

Control Output files

All output statements start with output keyword by default all output files will by located in output folder, the output filename by default will be the same source template file but without the extension ".t" This behavior can be customized using the output statements

Output Location

You can change the file name and file location using the following statement:

//## output location "./outout.cs" 

//## output location anyStringVariable 

That statement will override the distination file with the new file

Cancel the output override mode

To stop overriding files you can use this:

//##  output mode "DoNotOverride"

Output After

By default the output files will put output content in new file, but you can put the content inside the output file after speficit line using the following statement:

//## output after "//_some keyword in output file" 

//## output after anyStringVariable 

Please note that the output content will be checked not to be duplicated in the distination file

Output replace section

You can replace the whole section of content file if you provide both after and before keywords:

//## output after "//_begin block" 
//## output before "//_end block"
Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

Version Downloads Last updated
1.0.2 347 7/24/2021
1.0.1 342 7/23/2021
1.0.0 352 7/23/2021