cmdlore 0.4.0

A command library that lives in your shell
Documentation
version: 1

commands:

  - id: net.ping
    cmd:
      posix: ping -c <count:4> <host>
      powershell: ping -n <count:4> <host>
    desc: Check whether a host answers at all
    tags: [network, ping, reachable, latency]
    params:
      host:
        desc: Host name or address
      count:
        desc: How many packets to send

  - id: net.dns.resolve
    cmd: nslookup <host>
    desc: Check what a name actually resolves to right now
    tags: [network, dns, resolve, lookup, ip]
    params:
      host:
        desc: Name to look up

  - id: net.http.get
    cmd:
      posix: curl -sS <url>
      powershell: curl.exe -sS <url>
    desc: Fetch a page or an api response and print it
    tags: [network, http, curl, get, request]
    params:
      url:
        desc: Address to fetch

  - id: net.http.headers
    cmd:
      posix: curl -sSI -L <url>
      powershell: curl.exe -sSI -L <url>
    desc: Read the response headers and follow every redirect on the way
    tags: [network, http, curl, headers, redirect]
    params:
      url:
        desc: Address to fetch

  - id: net.http.download
    cmd:
      posix: curl -fsSL -o <file> <url>
      powershell: curl.exe -fsSL -o <file> <url>
    desc: Download a file, following redirects
    tags: [network, http, curl, download, file]
    params:
      file:
        desc: Name to save it as
      url:
        desc: Address to download

  - id: net.http.post-json
    cmd:
      posix: 'curl -sS -X POST -H "Content-Type: application/json" -d ''<body>'' <url>'
      powershell: 'curl.exe -sS -X POST -H "Content-Type: application/json" -d ''<body>'' <url>'
    desc: Send a JSON body to an endpoint without opening a client
    tags: [network, http, curl, post, json, api]
    params:
      url:
        desc: Endpoint to post to
      body:
        desc: JSON document to send

  - id: net.http.timing
    cmd:
      posix: 'curl -w "dns %{time_namelookup}s connect %{time_connect}s tls %{time_appconnect}s total %{time_total}s\n" -o /dev/null -s <url>'
      powershell: 'curl.exe -w "dns %{time_namelookup}s connect %{time_connect}s tls %{time_appconnect}s total %{time_total}s`n" -o NUL -s <url>'
    desc: Find out which part of a slow request is actually slow
    tags: [network, http, curl, timing, latency, slow]
    params:
      url:
        desc: Address to measure

  - id: net.tls.certificate
    cmd:
      posix: 'echo | openssl s_client -connect <host>:<port:443> -servername <host> 2>/dev/null | openssl x509 -noout -dates -subject -issuer'
    desc: Find out when a certificate expires and who issued it
    tags: [network, tls, ssl, certificate, expiry, openssl]
    params:
      host:
        desc: Host to connect to
      port:
        desc: Port the service listens on

  - id: net.reach.port
    cmd:
      posix: nc -vz -w <timeout:5> <host> <port>
      powershell: 'Test-NetConnection <host> -Port <port>'
    desc: Check whether a port is reachable before blaming the application
    tags: [network, port, reachable, firewall, netcat]
    params:
      host:
        desc: Host to reach
      port:
        desc: Port to try
      timeout:
        desc: Seconds to wait

  - id: net.route.trace
    cmd:
      posix: traceroute -n <host>
      powershell: 'Test-NetConnection <host> -TraceRoute'
    desc: See where packets stop when a host is unreachable
    tags: [network, traceroute, route, hops]
    params:
      host:
        desc: Host to trace

  - id: net.address.public
    cmd:
      posix: curl -sS https://ifconfig.me
      powershell: 'Invoke-RestMethod https://ifconfig.me'
    desc: Find the address this machine appears to come from
    tags: [network, ip, public, address, external]

  - id: net.interfaces
    cmd:
      posix: ifconfig
      powershell: 'Get-NetIPAddress | Select-Object InterfaceAlias, IPAddress, PrefixLength'
    desc: Read this machine's own addresses
    tags: [network, ip, interfaces, address, local]

  - id: net.serve.here
    cmd:
      posix: python3 -m http.server <port:8000>
      powershell: python -m http.server <port:8000>
    desc: Put the current directory on a port for one quick transfer
    tags: [network, http, server, share, python]
    params:
      port:
        desc: Port to listen on