diff --git a/examples/bitcoind.json b/examples/bitcoind.json new file mode 100644 index 0000000..2973799 --- /dev/null +++ b/examples/bitcoind.json @@ -0,0 +1,553 @@ +{ + "name": "/opt/bitcoin-24.0.1/bin/bitcoind", + "description": "Bitcoin Core daemon", + "usage": "bitcoind [options] Start Bitcoin Core", + "options": [ + { + "option": "-?", + "description": "Print this help message and exit" + }, + { + "option": "-addnode=", + "description": "Add a node to connect to and attempt to keep the connection open. This option can be specified multiple times to add multiple nodes; connections are limited to 8 at a time and are counted separately from the -maxconnections limit." + }, + { + "option": "-addresstype", + "description": "What type of addresses to use ('legacy', 'p2sh-segwit', 'bech32', or 'bech32m', default: 'bech32')" + }, + { + "option": "-alertnotify=", + "description": "Execute command when an alert is raised (%s in cmd is replaced by message)" + }, + { + "option": "-allowip=", + "description": "Allow JSON-RPC connections from specified source. Valid for are a single IP, a network/netmask or a network/CIDR. This option can be specified multiple times." + }, + { + "option": "-asmap=", + "description": "Specify asn mapping used for bucketing of the peers (default: ip_asn.map). Relative paths will be prefixed by the net-specific datadir location." + }, + { + "option": "-assumevalid=", + "description": "If this block is in the chain assume that it and its ancestors are valid and potentially skip their script verification. Default mainnet/testnet/signet values provided." + }, + { + "option": "-avoidpartialspends", + "description": "Group outputs by address, selecting many (possibly all) or none, instead of selecting on a per-output basis. Privacy is improved as addresses are mostly swept with fewer transactions and outputs are aggregated in clean change addresses. Always enabled for wallets with 'avoid_reuse' enabled, otherwise default: 0." + }, + { + "option": "-bantime=", + "description": "Default duration (in seconds) of manually configured bans (default: 86400)" + }, + { + "option": "-bind=[:][=onion]", + "description": "Bind to given address and always listen on it. Use [host]:port notation for IPv6. Append =onion to tag any incoming connections to that address and port as incoming Tor connections." + }, + { + "option": "-blockfilterindex=", + "description": "Maintain an index of compact filters by block (default: 0, values: basic). If is not supplied or if = 1, indexes for all known types are enabled." + }, + { + "option": "-blockmaxweight=", + "description": "Set maximum BIP141 block weight (default: 3996000)" + }, + { + "option": "-blockmintxfee=", + "description": "Set lowest fee rate (in BTC/kvB) for transactions to be included in block creation. (default: 0.00001)" + }, + { + "option": "-blocknotify=", + "description": "Execute command when the best block changes (%s in cmd is replaced by block hash)" + }, + { + "option": "-blockreconstructionextratxn=", + "description": "Extra transactions to keep in memory for compact block reconstructions (default: 100)" + }, + { + "option": "-blocksdir=", + "description": "Specify directory to hold blocks subdirectory for *.dat files (default: )" + }, + { + "option": "-blocksonly", + "description": "Whether to reject transactions from network peers. Automatic broadcast and rebroadcast of any transactions from inbound peers is disabled, unless the peer has the 'forcerelay' permission. RPC transactions are not affected. (default: 0)" + }, + { + "option": "-bytespersigop", + "description": "Equivalent bytes per sigop in transactions for relay and mining (default: 20)" + }, + { + "option": "-cjdnsreachable", + "description": "If set, then this host is configured for CJDNS (connecting to fc00::/8 addresses would lead us to the CJDNS network, see doc/cjdns.md) (default: 0)" + }, + { + "option": "-changetype", + "description": "What type of change to use ('legacy', 'p2sh-segwit', 'bech32', or 'bech32m'). Default is 'legacy' when -addresstype=legacy, else it is an implementation detail." + }, + { + "option": "-chain=", + "description": "Use the chain (default: main). Allowed values: main, test, signet, regtest" + }, + { + "option": "-coinstatsindex", + "description": "Maintain coinstats index used by the gettxoutsetinfo RPC (default: 0)" + }, + { + "option": "-conf=", + "description": "Specify path to read-only configuration file. Relative paths will be prefixed by datadir location (only useable from command line, not configuration file) (default: bitcoin.conf)" + }, + { + "option": "-consolidatefeerate=", + "description": "The maximum feerate (in BTC/kvB) at which transaction building may use more inputs than strictly necessary so that the wallet's UTXO pool can be reduced (default: 0.0001)." + }, + { + "option": "-connect=", + "description": "Connect only to the specified node; -noconnect disables automatic connections. This option can be specified multiple times to connect to multiple nodes." + }, + { + "option": "-datacarrier", + "description": "Relay and mine data carrier transactions (default: 1)" + }, + { + "option": "-datacarriersize", + "description": "Maximum size of data in data carrier transactions we relay and mine (default: 83)" + }, + { + "option": "-datadir=", + "description": "Specify data directory" + }, + { + "option": "-dbcache=", + "description": "Maximum database cache size MiB (4 to 16384, default: 450). In addition, unused mempool memory is shared for this cache (see -maxmempool)." + }, + { + "option": "-debug=", + "description": "Output debug and trace logging (default: -nodebug, supplying is optional). If is not supplied or if = 1, output all debug and trace logging." + }, + { + "option": "-debugexclude=", + "description": "Exclude debug and trace logging for a category. Can be used in conjunction with -debug=1 to output debug and trace logging for all categories except the specified category." + }, + { + "option": "-debuglogfile=", + "description": "Specify location of debug log file. Relative paths will be prefixed by a net-specific datadir location. (-nodebuglogfile to disable; default: debug.log)" + }, + { + "option": "-disablewallet", + "description": "Do not load the wallet and disable wallet RPC calls" + }, + { + "option": "-discover", + "description": "Discover own IP addresses (default: 1 when listening and no -externalip or -proxy)" + }, + { + "option": "-discardfee=", + "description": "The fee rate (in BTC/kvB) that indicates your tolerance for discarding change by adding it to the fee (default: 0.0001)." + }, + { + "option": "-dns", + "description": "Allow DNS lookups for -addnode, -seednode and -connect (default: 1)" + }, + { + "option": "-dnsseed", + "description": "Query for peer addresses via DNS lookup, if low on addresses (default: 1 unless -connect used)" + }, + { + "option": "-dandelion", + "description": "Enable dandelion mode (default: 1)" + }, + { + "option": "-daemon", + "description": "Run in the background as a daemon and accept commands (default: 0)" + }, + { + "option": "-daemonwait", + "description": "Wait for initialization to be finished before exiting. This implies -daemon (default: 0)" + }, + { + "option": "-externalip=", + "description": "Specify your own public address" + }, + { + "option": "-fallbackfee=", + "description": "A fee rate (in BTC/kvB) that will be used when fee estimation has insufficient data. 0 to entirely disable the fallbackfee feature. (default: 0.00)" + }, + { + "option": "-forcednsseed", + "description": "Always query for peer addresses via DNS lookup (default: 0)" + }, + { + "option": "-help-debug", + "description": "Print help message with debugging options and exit" + }, + { + "option": "-i2pacceptincoming", + "description": "If set and -i2psam is also set then incoming I2P connections are accepted via the SAM proxy." + }, + { + "option": "-i2psam=", + "description": "I2P SAM proxy to reach I2P peers and accept I2P connections (default: none)" + }, + { + "option": "-includeconf=", + "description": "Specify additional configuration file, relative to the -datadir path (only usable from configuration file, not command line)" + }, + { + "option": "-keypool=", + "description": "Set key pool size to (default: 1000)." + }, + { + "option": "-loadblock=", + "description": "Imports blocks from external file on startup" + }, + { + "option": "-logips", + "description": "Include IP addresses in debug output (default: 0)" + }, + { + "option": "-logsourcelocations", + "description": "Prepend debug output with name of the originating source location (source file, line number and function name) (default: 0)" + }, + { + "option": "-logthreadnames", + "description": "Prepend debug output with name of the originating thread (only available on platforms supporting thread_local) (default: 0)" + }, + { + "option": "-logtimestamps", + "description": "Prepend debug output with timestamp (default: 1)" + }, + { + "option": "-listen", + "description": "Accept connections from outside (default: 1 if no -proxy or -connect)" + }, + { + "option": "-listenonion", + "description": "Automatically create Tor onion service (default: 1)" + }, + { + "option": "-maxapsfee=", + "description": "Spend up to this amount in additional (absolute) fees (in BTC) if it allows the use of partial spend avoidance (default: 0.00)" + }, + { + "option": "-maxconnections=", + "description": "Maintain at most connections to peers (default: 125)." + }, + { + "option": "-maxmempool=", + "description": "Keep the transaction memory pool below megabytes (default: 300)" + }, + { + "option": "-maxorphantx=", + "description": "Keep at most unconnectable transactions in memory (default: 100)" + }, + { + "option": "-maxreceivebuffer=", + "description": "Maximum per-connection receive buffer, *1000 bytes (default: 5000)" + }, + { + "option": "-maxsendbuffer=", + "description": "Maximum per-connection send buffer, *1000 bytes (default: 1000)" + }, + { + "option": "-maxtimeadjustment", + "description": "Maximum allowed median peer time offset adjustment. Local perspective of time may be influenced by outbound peers forward or backward by this amount (default: 4200 seconds)." + }, + { + "option": "-maxuploadtarget=", + "description": "Tries to keep outbound traffic under the given target per 24h. Limit does not apply to peers with 'download' permission or blocks created within past week. 0 = no limit (default: 0M). Optional suffix units [k|K|m|M|g|G|t|T] (default: M)." + }, + { + "option": "-maxtxfee=", + "description": "Maximum total fees (in BTC) to use in a single wallet transaction; setting this too low may abort large transactions (default: 0.10)" + }, + { + "option": "-mempoolexpiry=", + "description": "Do not keep transactions in the mempool longer than hours (default: 336)" + }, + { + "option": "-mempoolfullrbf", + "description": "Accept transaction replace-by-fee without requiring replaceability signaling (default: 0)" + }, + { + "option": "-minrelaytxfee=", + "description": "Fees (in BTC/kvB) smaller than this are considered zero fee for relaying, mining and transaction creation (default: 0.00001)" + }, + { + "option": "-mintxfee=", + "description": "Fee rates (in BTC/kvB) smaller than this are considered zero fee for transaction creation (default: 0.00001)" + }, + { + "option": "-networkactive", + "description": "Enable all P2P network activity (default: 1). Can be changed by the setnetworkactive RPC command" + }, + { + "option": "-onion=", + "description": "Use separate SOCKS5 proxy to reach peers via Tor onion services, set -noonion to disable (default: -proxy)" + }, + { + "option": "-onlynet=", + "description": "Make automatic outbound connections only to network (ipv4, ipv6, onion, i2p, cjdns). Inbound and manual connections are not affected by this option. It can be specified multiple times to allow multiple networks." + }, + { + "option": "-par=", + "description": "Set the number of script verification threads (-12 to 15, 0 = auto, <0 = leave that many cores free, default: 0)" + }, + { + "option": "-paytxfee=", + "description": "Fee rate (in BTC/kvB) to add to transactions you send (default: 0.00)" + }, + { + "option": "-peerblockfilters", + "description": "Serve compact block filters to peers per BIP 157 (default: 0)" + }, + { + "option": "-peerbloomfilters", + "description": "Support filtering of blocks and transaction with bloom filters (default: 0)" + }, + { + "option": "-permitbaremultisig", + "description": "Relay non-P2SH multisig (default: 1)" + }, + { + "option": "-persistmempool", + "description": "Whether to save the mempool on shutdown and load on restart (default: 1)" + }, + { + "option": "-pid=", + "description": "Specify pid file. Relative paths will be prefixed by a net-specific datadir location. (default: bitcoind.pid)" + }, + { + "option": "-port=", + "description": "Listen for connections on . Nodes not using the default ports are unlikely to get incoming connections. Not relevant for I2P." + }, + { + "option": "-printtoconsole", + "description": "Send trace/debug info to console (default: 1 when no -daemon. To disable logging to file, set -nodebuglogfile)" + }, + { + "option": "-prune=", + "description": "Reduce storage requirements by enabling pruning (deleting) of old blocks. This allows the pruneblockchain RPC to be called to delete specific blocks and enables automatic pruning of old blocks if a target size in MiB is provided." + }, + { + "option": "-proxyrandomize", + "description": "Randomize credentials for every proxy connection. This enables Tor stream isolation (default: 1)" + }, + { + "option": "-proxy=", + "description": "Connect through SOCKS5 proxy, set -noproxy to disable (default: disabled)" + }, + { + "option": "-reindex", + "description": "Rebuild chain state and block index from the blk*.dat files on disk. This will also rebuild active optional indexes." + }, + { + "option": "-reindex-chainstate", + "description": "Rebuild chain state from the currently indexed blocks. When in pruning mode or if blocks on disk might be corrupted, use full -reindex instead. Deactivate all optional indexes before running this." + }, + { + "option": "-rest", + "description": "Accept public REST requests (default: 0)" + }, + { + "option": "-rpcallowip=", + "description": "Allow JSON-RPC connections from specified source. Valid for are a single IP, a network/netmask or a network/CIDR. This option can be specified multiple times" + }, + { + "option": "-rpcauth=", + "description": "Username and HMAC-SHA-256 hashed password for JSON-RPC connections. The field comes in the format: :$. This option can be specified multiple times" + }, + { + "option": "-rpcbind=[:port]", + "description": "Bind to given address to listen for JSON-RPC connections. Do not expose the RPC server to untrusted networks such as the public internet! This option is ignored unless -rpcallowip is also passed." + }, + { + "option": "-rpccookiefile=", + "description": "Location of the auth cookie. Relative paths will be prefixed by a net-specific datadir location. (default: data dir)" + }, + { + "option": "-rpcpassword=", + "description": "Password for JSON-RPC connections" + }, + { + "option": "-rpcport=", + "description": "Listen for JSON-RPC connections on (default: 8332, testnet: 18332, signet: 38332, regtest: 18443)" + }, + { + "option": "-rpcserialversion", + "description": "Sets the serialization of raw transaction or block hex returned in non-verbose mode, non-segwit(0) or segwit(1) (default: 1)" + }, + { + "option": "-rpcthreads=", + "description": "Set the number of threads to service RPC calls (default: 4)" + }, + { + "option": "-rpcuser=", + "description": "Username for JSON-RPC connections" + }, + { + "option": "-rpcwhitelist=", + "description": "Set a whitelist to filter incoming RPC calls for a specific user. The field comes in the format: :,,...,." + }, + { + "option": "-rpcwhitelistdefault", + "description": "Sets default behavior for rpc whitelisting. Unless rpcwhitelistdefault is set to 0, if any -rpcwhitelist is set, the rpc server acts as if all rpc users are subject to empty-unless-otherwise-specified whitelists." + }, + { + "option": "-sandbox=", + "description": "Use the experimental syscall sandbox in the specified mode (-sandbox=log-and-abort or -sandbox=abort)." + }, + { + "option": "-seednode=", + "description": "Connect to a node to retrieve peer addresses, and disconnect. This option can be specified multiple times to connect to multiple nodes." + }, + { + "option": "-server", + "description": "Accept command line and JSON-RPC commands" + }, + { + "option": "-settings=", + "description": "Specify path to dynamic settings data file. Can be disabled with -nosettings. File is written at runtime and not meant to be edited by users (use bitcoin.conf instead for custom settings)." + }, + { + "option": "-shrinkdebugfile", + "description": "Shrink debug.log file on client startup (default: 1 when no -debug)" + }, + { + "option": "-signer=", + "description": "External signing tool, see doc/external-signer.md" + }, + { + "option": "-signet", + "description": "Use the signet chain. Equivalent to -chain=signet. Note that the network is defined by the -signetchallenge parameter" + }, + { + "option": "-signetchallenge", + "description": "Blocks must satisfy the given script to be considered valid (only for signet networks; defaults to the global default signet test network challenge)" + }, + { + "option": "-signetseednode", + "description": "Specify a seed node for the signet network, in the hostname[:port] format." + }, + { + "option": "-spendzeroconfchange", + "description": "Spend unconfirmed change when sending transactions (default: 1)" + }, + { + "option": "-startupnotify=", + "description": "Execute command on startup." + }, + { + "option": "-sysperms", + "description": "Create new files with system default permissions, instead of umask 077 (only effective with disabled wallet functionality)" + }, + { + "option": "-testnet", + "description": "Use the test chain. Equivalent to -chain=test." + }, + { + "option": "-timeout=", + "description": "Specify socket connection timeout in milliseconds. If an initial attempt to connect is unsuccessful after this amount of time, drop it (minimum: 1, default: 5000)" + }, + { + "option": "-torcontrol=:", + "description": "Tor control port to use if onion listening enabled (default: 127.0.0.1:9051)" + }, + { + "option": "-torpassword=", + "description": "Tor control port password (default: empty)" + }, + { + "option": "-txconfirmtarget=", + "description": "If paytxfee is not set, include enough fee so transactions begin confirmation on average within n blocks (default: 6)" + }, + { + "option": "-txindex", + "description": "Maintain a full transaction index, used by the getrawtransaction rpc call (default: 0)" + }, + { + "option": "-uacomment=", + "description": "Append comment to the user agent string" + }, + { + "option": "-version", + "description": "Print version and exit" + }, + { + "option": "-wallet=", + "description": "Specify wallet path to load at startup. Can be used multiple times to load multiple wallets." + }, + { + "option": "-walletbroadcast", + "description": "Make the wallet broadcast transactions (default: 1)" + }, + { + "option": "-walletdir=", + "description": "Specify directory to hold wallets (default: /wallets if it exists, otherwise )" + }, + { + "option": "-walletnotify=", + "description": "Execute command when a wallet transaction changes." + }, + { + "option": "-walletrbf", + "description": "Send transactions with full-RBF opt-in enabled (RPC only, default: 1)" + }, + { + "option": "-whitebind=<[permissions@]addr>", + "description": "Bind to the given address and add permission flags to the peers connecting to it. Use [host]:port notation for IPv6. Specify multiple permissions separated by commas." + }, + { + "option": "-whitelist=<[permissions@]IP address or network>", + "description": "Add permission flags to the peers connecting from the given IP address or CIDR-notated network. Uses the same permissions as -whitebind. Can be specified multiple times." + }, + { + "option": "-whitelistforcerelay", + "description": "Add 'forcerelay' permission to whitelisted inbound peers with default permissions. This will relay transactions even if the transactions were already in the mempool. (default: 0)" + }, + { + "option": "-whitelistrelay", + "description": "Add 'relay' permission to whitelisted inbound peers with default permissions. This will accept relayed transactions even when not relaying transactions (default: 1)" + }, + { + "option": "-zmqpubhashblock=
", + "description": "Enable publish hash block in
" + }, + { + "option": "-zmqpubhashblockhwm=", + "description": "Set publish hash block outbound message high water mark (default: 1000)" + }, + { + "option": "-zmqpubhashtx=
", + "description": "Enable publish hash transaction in
" + }, + { + "option": "-zmqpubhashtxhwm=", + "description": "Set publish hash transaction outbound message high water mark (default: 1000)" + }, + { + "option": "-zmqpubrawblock=
", + "description": "Enable publish raw block in
" + }, + { + "option": "-zmqpubrawblockhwm=", + "description": "Set publish raw block outbound message high water mark (default: 1000)" + }, + { + "option": "-zmqpubrawtx=
", + "description": "Enable publish raw transaction in
" + }, + { + "option": "-zmqpubrawtxhwm=", + "description": "Set publish raw transaction outbound message high water mark (default: 1000)" + }, + { + "option": "-zmqpubsequence=
", + "description": "Enable publish hash block and tx sequence in
" + }, + { + "option": "-zmqpubsequencehwm=", + "description": "Set publish hash sequence message high water mark (default: 1000)" + } + ], + "subcommands": [], + "version": "v24.0.1" +} diff --git a/examples/ollama.json b/examples/ollama.json new file mode 100644 index 0000000..e4fb34e --- /dev/null +++ b/examples/ollama.json @@ -0,0 +1,281 @@ +{ + "name": "ollama", + "description": "Large language model runner", + "usage": "ollama [flags] | ollama [command]", + "subcommands": [ + { + "name": "ollama cp", + "description": "Copy a model", + "usage": "ollama cp SOURCE DESTINATION [flags]", + "options": [ + { + "description": "help for cp", + "option": "--help", + "shortcut": "-h" + } + ], + "subcommands": [] + }, + { + "name": "ollama create", + "description": "A command-line tool for creating models.", + "usage": "ollama create MODEL [flags]", + "subcommands": [], + "options": [ + { + "option": "--file", + "shortcut": "-f", + "description": "Name of the Modelfile", + "value": "string", + "default": "Modelfile" + }, + { + "option": "--help", + "shortcut": "-h", + "description": "help for create" + }, + { + "option": "--quantize", + "shortcut": "-q", + "description": "Quantize model to this level (e.g. q4_K_M)", + "value": "string" + } + ] + }, + { + "name": "ollama list", + "description": "A command-line tool to manage models.", + "usage": "ollama [command] [flags]", + "subcommands": [], + "options": [ + { + "option": "--help", + "shortcut": "-h", + "description": "help for list" + } + ] + }, + { + "name": "ollama ps", + "description": "List running models", + "usage": "ollama ps [flags]", + "options": [ + { + "option": "--help", + "shortcut": "-h", + "description": "help for ps" + } + ], + "environment_variables": [ + { + "name": "OLLAMA_HOST", + "description": "IP Address for the ollama server", + "default": "127.0.0.1:11434" + } + ], + "subcommands": [] + }, + { + "name": "ollama pull", + "description": "Pull a model from a registry", + "usage": "ollama pull MODEL [flags]", + "subcommands": [], + "options": [ + { + "option": "--help", + "shortcut": "-h", + "description": "help for pull" + }, + { + "option": "--insecure", + "description": "Use an insecure registry" + } + ] + }, + { + "name": "ollama push", + "description": "Push a model to a registry", + "usage": "ollama push MODEL [flags]", + "subcommands": [], + "options": [ + { + "option": "--help", + "shortcut": "-h", + "description": "help for push" + }, + { + "option": "--insecure", + "description": "Use an insecure registry" + } + ] + }, + { + "name": "ollama run", + "description": "Run a model", + "usage": "ollama run MODEL [PROMPT] [flags]", + "subcommands": [], + "options": [ + { + "option": "--format", + "description": "Response format (e.g. json)", + "value": "string" + }, + { + "option": "--help", + "shortcut": "-h", + "description": "help for run" + }, + { + "option": "--hidethinking", + "description": "Hide thinking output (if provided)" + }, + { + "option": "--insecure", + "description": "Use an insecure registry" + }, + { + "option": "--keepalive", + "description": "Duration to keep a model loaded (e.g. 5m)", + "value": "string" + }, + { + "option": "--nowordwrap", + "description": "Don't wrap words to the next line automatically" + }, + { + "option": "--think", + "description": "Enable thinking mode: true/false or high/medium/low for supported models", + "value": "string", + "default": "true" + }, + { + "option": "--verbose", + "description": "Show timings for response" + } + ] + }, + { + "name": "ollama serve", + "description": "Manage the ollama server and its operations.", + "usage": "ollama serve [flags]", + "subcommands": [], + "options": [ + { + "option": "--help", + "shortcut": "-h", + "description": "help for serve" + } + ] + }, + { + "name": "ollama show", + "description": "Show information for a model", + "usage": "ollama show MODEL [flags]", + "subcommands": [], + "options": [ + { + "option": "--help", + "shortcut": "-h", + "description": "help for show" + }, + { + "option": "--license", + "description": "Show license of a model" + }, + { + "option": "--modelfile", + "description": "Show Modelfile of a model" + }, + { + "option": "--parameters", + "description": "Show parameters of a model" + }, + { + "option": "--system", + "description": "Show system message of a model" + }, + { + "option": "--template", + "description": "Show template of a model" + }, + { + "option": "--verbose", + "shortcut": "-v", + "description": "Show detailed model information" + } + ] + }, + { + "name": "ollama signin", + "description": "Sign in to ollama.com", + "usage": "ollama signin [flags]", + "subcommands": [], + "options": [ + { + "option": "--help", + "shortcut": "-h", + "description": "help for signin" + } + ] + }, + { + "name": "ollama signout", + "description": "Sign out from ollama.com", + "usage": "ollama signout [flags]", + "subcommands": [], + "options": [ + { + "option": "--help", + "shortcut": "-h", + "description": "help for signout" + } + ] + }, + { + "name": "ollama stop", + "description": "Stop a running model", + "usage": "ollama stop MODEL [flags]", + "subcommands": [], + "options": [ + { + "option": "--help", + "shortcut": "-h", + "description": "help for stop" + } + ], + "environmentVariables": [ + { + "name": "OLLAMA_HOST", + "description": "IP Address for the ollama server", + "default": "127.0.0.1:11434" + } + ] + }, + { + "name": "ollama rm", + "description": "Remove a model", + "usage": "ollama rm MODEL [MODEL...] [flags]", + "subcommands": [], + "options": [ + { + "option": "--help", + "shortcut": "-h", + "description": "help for rm" + } + ] + } + ], + "options": [ + { + "option": "--help", + "shortcut": "-h", + "description": "help for ollama" + }, + { + "option": "--version", + "shortcut": "-v", + "description": "Show version information" + } + ], + "version": "0.12.6" +} diff --git a/src/parser.py b/src/parser.py index c326393..a59d19e 100644 --- a/src/parser.py +++ b/src/parser.py @@ -43,6 +43,8 @@ def download_and_extract(url, dest="/usr/local/bin"): file_path = download_file(url, dest) return extract_file(file_path, dest) +DOCKER_IMAGE = None + def call_command(binary, commands): """ Calls the specified command for the binary and returns the output. @@ -58,10 +60,14 @@ def call_command(binary, commands): Exception: If all attempts to get command output fail. """ for command in commands: - cmd = ([binary] if len(binary.split()) < 2 else binary.split()) + command + if DOCKER_IMAGE: + cmd = ["docker", "run", "--rm", DOCKER_IMAGE, binary] + command + else: + cmd = ([binary] if len(binary.split()) < 2 else binary.split()) + command result = subprocess.run(cmd, capture_output=True, text=True) - if result.returncode == 0: - return result.stdout.strip() + output = result.stdout.strip() or result.stderr.strip() + if output: + return output raise Exception(f"Failed to get output for {binary} with commands {commands}") def call_help(binary, command=None): @@ -182,7 +188,7 @@ def analyze_binary_version(binary): print(str(e)) return None -def main(binary_name, url=None, mongodb_url=None, override=False): +def main(binary_name, url=None, mongodb_url=None, override=False, docker_image=None): """ Main function to analyze a binary's help output and optionally save the results to MongoDB. @@ -191,7 +197,10 @@ def main(binary_name, url=None, mongodb_url=None, override=False): url (str, optional): URL to download the binary or archive file. Defaults to None. mongodb_url (str, optional): MongoDB connection string. Defaults to None. override (bool, optional): Whether to override existing document if it exists. Defaults to False. + docker_image (str, optional): Docker image to run the binary in. Defaults to None. """ + global DOCKER_IMAGE + DOCKER_IMAGE = docker_image db = None if mongodb_url: client = MongoClient(mongodb_url) @@ -234,6 +243,7 @@ def main(binary_name, url=None, mongodb_url=None, override=False): parser.add_argument("--url", type=str, help="Optional URL to download the binary or archive file") parser.add_argument("--override", action='store_true', help="Override existing document if it exists") parser.add_argument("--mongodb-url", type=str, help="MongoDB connection string") + parser.add_argument("--docker", type=str, help="Docker image to run the binary in") args = parser.parse_args() @@ -242,4 +252,4 @@ def main(binary_name, url=None, mongodb_url=None, override=False): parser.print_help() exit(1) - main(args.binary_name, args.url, args.mongodb_url, args.override) + main(args.binary_name, args.url, args.mongodb_url, args.override, args.docker)