Viscacha.CLI 1.1.0

dotnet tool install --global Viscacha.CLI --version 1.1.0
                    
This package contains a .NET tool you can call from the shell/command line.
dotnet new tool-manifest
                    
if you are setting up this repo
dotnet tool install --local Viscacha.CLI --version 1.1.0
                    
This package contains a .NET tool you can call from the shell/command line.
#tool dotnet:?package=Viscacha.CLI&version=1.1.0
                    
nuke :add-package Viscacha.CLI --version 1.1.0
                    

Viscacha CLI

A simple command-line tool for quickly testing REST API endpoints defined in YAML files. It supports variable substitution, authentication, and response handling, making it easy to automate and test API interactions.

Features

  • Execute HTTP requests defined in YAML files.
  • Supports multiple HTTP methods (GET, POST, PUT, PATCH, DELETE, etc.).
  • Variable substitution from environment variables, command-line arguments, and previous responses.
  • Supports authentication methods:
    • API Key Authentication
    • Azure Credentials Authentication
  • Easy-to-read JSON formatted responses.

Usage

viscacha <yaml-file> [--var name=value ...]

Example

viscacha requests.yaml --var userId=123 --var token=abcdef

YAML File Structure

You can define requests in YAML files as follows:

defaults:
  baseUrl: https://api.example.com
  headers:
    Accept: application/json
  authentication:
    type: api-key
    key: ${API_KEY}

requests:
  - method: GET
    path: /users/{{userId}}

  - method: POST
    path: /users
    contentType: application/json
    body: |
      {
        "name": "John Doe",
        "email": "john@example.com"
      }

Variable Substitution

  • Environment variables: ${env:VARIABLE_NAME}
  • Command-line variables: ${variableName}
  • Response variables: #{r0.propertyName} (where r0 is the response from the first request)

Authentication Examples

API Key Authentication
authentication:
  type: api-key
  key: your-api-key
  header: X-Api-Key
  prefix: Bearer
Azure Credentials Authentication
authentication:
  type: azure-credentials
  scopes:
    - https://management.azure.com/.default

Importing Defaults

You can import default settings from another YAML file using the import property within the defaults section. This allows you to reuse common configurations across multiple YAML files.

Example:

defaults:
  import: common-defaults.yaml

Additionally, defaults can be imported from the command line:

viscacha <request-file> --defaults <defaults-file>

If defaults are provided using multiple mechanisms, the order of precedence is as follows: first, those provided via the command line, then those embedded in the file, and finally those imported in the file.

License

This project is licensed under the MIT License.

Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

Version Downloads Last Updated
1.1.0 221 3/20/2025
1.0.0 196 3/18/2025
0.1.0 188 3/18/2025