-
Notifications
You must be signed in to change notification settings - Fork 1
Init script wrapper #85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
elenabardho
wants to merge
3
commits into
main
Choose a base branch
from
wrapper
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,108 @@ | ||
| #!/bin/bash | ||
|
|
||
| ################################################## | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. a wrapper is quite nice |
||
| # Governance Scripts CLI Wrapper | ||
elenabardho marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| # 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) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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) | ||
elenabardho marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| exec "$SCRIPTS_DIR/query-live-actions.sh" "$@" | ||
| ;; | ||
| -h|--help|help) | ||
| usage | ||
| ;; | ||
| *) | ||
| echo -e "${RED}Error: Unknown command '${COMMAND}'${NC}" >&2 | ||
| echo "" | ||
| usage | ||
| ;; | ||
| esac | ||
This file was deleted.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.