5.1.3 • Published 8 months ago

jji v5.1.3

Weekly downloads
-
License
MIT
Repository
github
Last release
8 months ago

jji

Just a simple Jumper clI tool.

This tool aims to make an easy menu system to organize your cli workflow.

Just run jj if you have jj.js file or *.jj.js files in the current folder.

Install

npm i -g jji

How menu structure works

  • every menu item has name: module.export.test
  • every menu item has command which can be: ss - simple script, ff - featured function or null
  • every menu item optionally can have a description. in this case the definition change to array where description is on the first place: module.exports.run = ["run simple", ss("echo hello")]
  • every menu item can have sub menu which can be after description or after command (it called as group)
    • after description: module.exports.group_name = ["group description", {...}]
    • after command: module.exports.group_name = ["group description", ss("echo hello"), {...}]
  • every group can have a group command which can be: ss - simple script
  • when one item selected, all group command and item command going to be concatenated into one string and executed in node spawn shell
  • there are 3 extra type of menu item:
    • lazy load menu - ff.lazy.do(async (resolve)=>{...}), which means when you enter into the menu the Promise start after the select
    • slow menu - ff.menu.do(async (resolve)=>{...}), which means the Promise start after the program start
    • read only - null, not selectable menu item

Examples

Menu control keys

  • arrow-up/down and tab: up/down in the menu
  • select: enter
  • one level up: esc
  • on top level: esc equals exit
  • terminate: ctrl+c
  • clear screen: ctrl+l
  • fly mode start: ctrl+space or text start with space

Features

  • possible to run script from jj.js or *.jj.js
  • if the working folder contains *.jj.js possible to sort with number. ex. *.0.jj,js *.1.jj,js
  • prompt base sub menu system, please check the example/demo/jj.js#L1
  • search in the menu and in descriptions
  • all script runs inside a node spawn
  • provided global functions, which means you do not need to import anything for use in your *.jj.js file:
    • ss - simple script
    • ff - featured function
    • jj - just jump extra functions

Global functions

ss - simple script
ff - featured function
jj - just jump extra functions

jj for a jj global function access. In your javascript code you can use the followings:

  • 'jj.home()' which will reopen the menu on the top (root) level after the function finish
  • 'jj.stay()' which will reopen the menu on the same level after the function finish
  • 'jj.rl': const rl = await jj.rl('Type your name') which will read a line from stdin. One parameter is the question.
  • 'jj.err': jj.err('Something went wrong!') this will print an error msg if exist and exit the program.
  • 'jj.mkdir': await jj.mkdir('/path/to') this will create a folder recursively.
  • 'jj.rm': await jj.rm('/path/to') this will remove a folder recursively.
  • jj.cl*.do which run a simple script:

    • global control properties for jji workflow:
      • process.env.__shell boolean true means all spawn command will be executed in shell.
    • 'jj.cl.do': which run a simple script with inherited stdio. The output simple printed:jj.cl.do(`echo hello wold`). possible to combine with fix parameter between array. jj.cl.do(``docker exec alpine sh -c``, [``ls -al``]); or jj.cl.do(``docker exec alpine sh -c``, [``ls -al``], ``/usr``, [``/path with space``]);
    • 'jj.cli.do' which run a simple script. same as jj.cl, but output is not printed and parsed. Example:const a = await jj.cli.do(`echo other done other`); console.log(a). default: no split. Possible to add extra parameters (option object place in the arguments list no matter):
      • splitByLine: the output will not be split: await jj.cli.splitByLine.do(``echo ${false}``, 'other'); example/demo/jj.js#L76
      • splitAll: the output will be split by line and split lines by space and tab: await jj.cli.splitAll.do(``echo ${false}``, ); example/demo/jj.js#L84
      • hideErr: the output will not contains stderr output: await jj.cli.hideErr.do(``echo ${false}``, 'other');. default: include
      • wd: set the current directory: await jj.cli.wd('/path/to').do(``echo ${false}``, 'other');. default: undefined
      • eol: set end of line characters: await jj.cli.eol('\r\n').do(``echo ${false}`` 'other');. default: \n
  • 'ff.lazy.do' for a lazy load menu, which means when you enter into the menu the Promise start after the enter. First parameter is a promise call back function, the second is a description, the third is a command. Example:ff.lazy.do(async (res)=>{}, {options})

  • '$' for a option extend, which means extra options extends the original function. Example:$$$((res, rej)=>{}, {options})

  • all command which are functions, can have options:

  • all boolean property is available on global scope because of shorter definition. example: await __(``hi ${false}``, { __splitByLine: true }, 'other'); ==> await __(``hi ${false}``, { __splitByLine }, 'other');

Usage

commanddescription
jjit gives a nice choices menu
jj -hgives a standard help manual

Status

  • support menu for select a script
  • fly mode
5.1.3

8 months ago

5.1.2

8 months ago

5.1.1

9 months ago

5.1.0

9 months ago

5.0.1

1 year ago

5.0.0

1 year ago

4.1.0

1 year ago

4.1.1

1 year ago

4.0.5

2 years ago

4.0.4

2 years ago

4.0.10

2 years ago

4.0.7

2 years ago

4.0.6

2 years ago

4.0.12

2 years ago

4.0.11

2 years ago

4.0.14

2 years ago

4.0.13

2 years ago

4.0.9

2 years ago

4.0.8

2 years ago

4.0.1

2 years ago

4.0.0

2 years ago

4.0.3

2 years ago

4.0.2

2 years ago

2.2.1

3 years ago

2.2.0

3 years ago

2.0.2

3 years ago

2.2.3

2 years ago

2.2.2

3 years ago

2.2.5

2 years ago

2.2.4

2 years ago

2.2.7

2 years ago

2.2.6

2 years ago

3.0.0

2 years ago

2.1.2

3 years ago

2.1.1

3 years ago

2.1.0

3 years ago

2.0.1

3 years ago

2.0.0

3 years ago

1.0.55

3 years ago

1.0.54

3 years ago

1.0.53

3 years ago

1.0.56

3 years ago

1.0.48

3 years ago

1.0.47

3 years ago

1.0.46

3 years ago

1.0.49

3 years ago

1.0.51

3 years ago

1.0.50

3 years ago

1.0.52

3 years ago

1.0.19

3 years ago

1.0.18

3 years ago

1.0.39

3 years ago

1.0.17

3 years ago

1.0.38

3 years ago

1.0.16

3 years ago

1.0.40

3 years ago

1.0.44

3 years ago

1.0.22

3 years ago

1.0.43

3 years ago

1.0.21

3 years ago

1.0.42

3 years ago

1.0.20

3 years ago

1.0.41

3 years ago

1.0.26

3 years ago

1.0.25

3 years ago

1.0.24

3 years ago

1.0.45

3 years ago

1.0.23

3 years ago

1.0.29

3 years ago

1.0.28

3 years ago

1.0.27

3 years ago

1.0.33

3 years ago

1.0.11

3 years ago

1.0.32

3 years ago

1.0.31

3 years ago

1.0.30

3 years ago

1.0.37

3 years ago

1.0.15

3 years ago

1.0.36

3 years ago

1.0.14

3 years ago

1.0.35

3 years ago

1.0.13

3 years ago

1.0.34

3 years ago

1.0.12

3 years ago

1.0.10

3 years ago

1.0.9

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago