Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 89 additions & 0 deletions docs/cli-setup.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# CLI Setup

The governance scripts can be used as a unified CLI tool.

## Installation

### Option 1: Add to PATH (Recommended)

Add the repository directory to your PATH in your shell configuration file:

**For Zsh (macOS default):**
```bash
echo 'export PATH="$PATH:/Users/elenabardho/Cardano/governance-scripts"' >> ~/.zshrc
source ~/.zshrc
```

**For Bash:**
```bash
echo 'export PATH="$PATH:/Users/elenabardho/Cardano/governance-scripts"' >> ~/.bashrc
source ~/.bashrc
```

After this, you can use `governance` from anywhere.

### Option 2: Create a Symlink

Create a symlink in a directory that's already in your PATH:

```bash
sudo ln -s /Users/elenabardho/Cardano/governance-scripts/governance /usr/local/bin/governance
```

### Option 3: Use with Full Path

Run directly from the repository:

```bash
/Users/elenabardho/Cardano/governance-scripts/governance <command>
```

Or create an alias:

```bash
echo 'alias governance="/Users/elenabardho/Cardano/governance-scripts/governance"' >> ~/.zshrc
source ~/.zshrc
```

## Usage

Once installed, use the CLI like this:

```bash
# Show help
governance --help

# Create metadata from markdown
governance metadata-create input.md --governance-action-type info --deposit-return-addr stake1...

# Sign metadata with author
governance author-create metadata.jsonld signing-key.skey --author-name "Your Name"

# Validate metadata
governance metadata-validate metadata.jsonld

# Create info action
governance action-info metadata.jsonld

# Query live actions
governance query-actions

# Get help for a specific command
governance metadata-create --help
```

## Available Commands

- `author-create` - Sign metadata files with author witness
- `author-validate` - Validate author signatures in metadata
- `action-info` - Create an Info action from JSON-LD metadata
- `action-treasury` - Create a Treasury Withdrawal action
- `metadata-create` - Create JSON-LD metadata from Markdown
- `metadata-validate` - Validate JSON-LD metadata
- `metadata-canonize` - Canonize JSON-LD metadata
- `cip108-human` - Create human-readable CIP-108 format
- `hash` - Hash a file
- `ipfs-check` - Check IPFS pinning status
- `ipfs-pin` - Pin files to IPFS
- `pdf-remove-metadata` - Remove metadata from PDF files
- `query-actions` - Query live governance actions
108 changes: 108 additions & 0 deletions governance.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
#!/bin/bash

##################################################
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a wrapper is quite nice
it could allow us to load custom configs

# Governance Scripts CLI Wrapper
# Provides a unified interface to all governance scripts
##################################################

set -euo pipefail

# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
BLUE='\033[0;34m'
CYAN='\033[0;36m'
NC='\033[0m'
UNDERLINE='\033[4m'
BOLD='\033[1m'
GRAY='\033[0;90m'

# Get the directory where this script is located
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
SCRIPTS_DIR="$SCRIPT_DIR/scripts"

# Usage message
usage() {
echo -e "${UNDERLINE}${BOLD}Governance Scripts CLI${NC}"
echo -e "\n"
echo -e "Usage: ${BOLD}governance ${GREEN}<command>${NC} [options]"
echo -e "\n"
echo -e "${BOLD}Available Commands:${NC}"
echo -e " ${GREEN}author-create${NC} Sign metadata files with author witness"
echo -e " ${GREEN}author-validate${NC} Validate author signatures in metadata"
echo -e " ${GREEN}action-info${NC} Create an Info action from JSON-LD metadata"
echo -e " ${GREEN}action-treasury${NC} Create a Treasury Withdrawal action"
echo -e " ${GREEN}metadata-create${NC} Create JSON-LD metadata from Markdown"
echo -e " ${GREEN}metadata-validate${NC} Validate JSON-LD metadata"
echo -e " ${GREEN}metadata-canonize${NC} Canonize JSON-LD metadata"
echo -e " ${GREEN}cip108-human${NC} Create human-readable CIP-108 format"
echo -e " ${GREEN}hash${NC} Hash a file"
echo -e " ${GREEN}ipfs-check${NC} Check IPFS pinning status"
echo -e " ${GREEN}ipfs-pin${NC} Pin files to IPFS"
echo -e " ${GREEN}pdf-remove-metadata${NC} Remove metadata from PDF files"
echo -e "\n"
echo -e "Use ${BOLD}governance ${GREEN}<command>${NC} ${YELLOW}-h${NC} for more information about a specific command"
echo -e "\n"
exit 1
}

# Check if at least one argument is provided
if [ $# -eq 0 ]; then
usage
fi

# Get the command
COMMAND="$1"
shift

# Map commands to script files
case "$COMMAND" in
author-create)
exec "$SCRIPTS_DIR/author-create.sh" "$@"
;;
author-validate)
exec "$SCRIPTS_DIR/author-validate.sh" "$@"
;;
action-info)
exec "$SCRIPTS_DIR/action-create-info.sh" "$@"
;;
action-treasury)
exec "$SCRIPTS_DIR/action-create-tw.sh" "$@"
;;
metadata-create)
exec "$SCRIPTS_DIR/metadata-create.sh" "$@"
;;
metadata-validate)
exec "$SCRIPTS_DIR/metadata-validate.sh" "$@"
;;
metadata-canonize)
exec "$SCRIPTS_DIR/metadata-canonize.sh" "$@"
;;
cip108-human)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe a rename on this script, WDTY?

exec "$SCRIPTS_DIR/cip-108-create-human-readable.sh" "$@"
;;
hash)
exec "$SCRIPTS_DIR/hash.sh" "$@"
;;
ipfs-check)
exec "$SCRIPTS_DIR/ipfs-check.sh" "$@"
;;
ipfs-pin)
exec "$SCRIPTS_DIR/ipfs-pin.sh" "$@"
;;
pdf-remove-metadata)
exec "$SCRIPTS_DIR/pdf-remove-metadata.sh" "$@"
;;
query-actions)
exec "$SCRIPTS_DIR/query-live-actions.sh" "$@"
;;
-h|--help|help)
usage
;;
*)
echo -e "${RED}Error: Unknown command '${COMMAND}'${NC}" >&2
echo ""
usage
;;
esac
49 changes: 0 additions & 49 deletions scripts/query-live-actions.sh

This file was deleted.