vivjson.command_line (2025-03-28)
index
https://github.com/benesult/vivjson-python/tree/main/vivjson/command_line.py

Command-line client for VivJson
 
Usage: vivjson [ [option] <code or file> ... ]
         or
       python3 -m vivjson [ [option] <code or file> ... ]
 
option: - "+" is concatenated the previous code and
          the following code, such as
            "a=" + "[1, 2]" "return(a[0]+a[1])"
        - "-i" or "--stdin" reads from PIPE.
          For example, the following command shows "6".
            echo '{"a":3}' | vivjson -i "return(a*2)"
          "-i=<name>" or "--stdin=<name>" gives variable name for
          value that read from PIPE.
          For example, the following command shows
          {"dog": 2, "cat": 3}.
            echo '[{"x":"dog","y":2},{"x":"cat","y":3}]' |             vivjson -i=data "z={},for(v in data){z[v.x]=v.y},print(z)"
        - "-j" or "--json" indicates that the following code is JSON.
          For example, error occurs because the following value is
          invalid as JSON.
            vivjson -j '{"a":1+2}'
        - "-v" or "--version" shows version.
 
Environment:
- Python 3.9 or later
 
License:
Copyright 2025 benesult
 
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
 
    http://www.apache.org/licenses/LICENSE-2.0
 
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

 
Modules
       
sys

 
Functions
       
get_stdin()
Get data or command from stdin.
 
Returns:
    str or NoneType: data/command if it is given,
                     None otherwise.
is_number(text: str) -> bool
Detect whether the given text is number or not.
 
Args:
    text (str): A text that may be number
 
Returns:
    bool: True if the given text is number, False otherwise
main()
Main function for command line.
show_usage()
Show usage of VivJson in command line.
show_version()
Show version of VivJson in command line.

 
Author
        Fumiaki Motegi <motegi@benesult.com>