SOURCE

function order(userCli) {
    let dataList = []
    const ret = userCli.split(' ')
    const cli = ret[0]
    const argc = userCli.replace(cli+' ','')
    const argcs = argc.split(' ')
    argcs.forEach(element => {
        const arr = element.split('=')
        const str = `{${JSON.stringify(arr[0])}:${JSON.stringify(arr[1])}}`
        dataList.push(JSON.parse(str))
    });
    return {
        cli:cli,
        argc:dataList
    }
}

// 来自用户的输入命令,转换json
let res = order('hello name=zhangshan age=18')
console.log(res)
console 命令行工具 X clear

                    
>
console