1.0.3 • Published 11 months ago

nv-cli-nest-if-from-dict v1.0.3

Weekly downloads
-
License
ISC
Repository
-
Last release
11 months ago

nv-cli-nest-if-from-dict

  • cli-tool
  • creat nest if branches with a json-dict

install

  • npm install nv-cli-nest-if-from-dict -g

usage

Usage: nv_cli_nest_if_from_dict [options] 
Options:
    -I, --indent           top layer indent, default 0
    -c, --constexpr        using if constexpr
    -i, --input            input string ,default stdin
    -o, --output           output string,default stdout
    -h, --help             usage

example

     # nv_cli_nest_if_from_dict  -c 

     // PASTE JSON(dict only , "" means else) HERE :
	{
	   "a>200": {
	       "a%3 == 0": "return(1000);",
	       "a%3 == 1": "return(2000);",
	       ""        : "return(3000);",
	   },
	   "a>100": {
	       "a%3 == 0": "return(100);",
	       "a%3 == 1": "return(200);",
	       ""        : "return(300);",
	   },
	   "": {
	       "a%3 == 0": "return(10);",
	       "a%3 == 1": "return(20);",
	       ""        : "return(30);",   
	   }   
	}
      
     // PRESS ctrl+D


	if constexpr(a>200) {
	    if constexpr(a%3 == 0) {
		return(1000);
	    } else if constexpr(a%3 == 1) {
		return(2000);
	    } else {
		return(3000);
	    }
	} else if constexpr(a>100) {
	    if constexpr(a%3 == 0) {
		return(100);
	    } else if constexpr(a%3 == 1) {
		return(200);
	    } else {
		return(300);
	    }
	} else {
	    if constexpr(a%3 == 0) {
		return(10);
	    } else if constexpr(a%3 == 1) {
		return(20);
	    } else {
		return(30);
	    }
	}
           

LICENSE

  • ISC