feat: implement role-based configuration system for CLI with automatic API key management
- Add role detection to command groups (admin, client, miner, blockchain)
- Load role-specific config files (~/.aitbc/{role}-config.yaml)
- Add role field to Config class with environment variable support
- Implement automatic role detection from invoked subcommand
- Add development mode API key bypass for testing (APP_ENV=dev)
- Update CLI checklist with role-based configuration documentation
- Add configuration override priority and
This commit is contained in:
@@ -8,9 +8,12 @@ from ..utils import output, error, success
|
||||
|
||||
|
||||
@click.group()
|
||||
def admin():
|
||||
@click.pass_context
|
||||
def admin(ctx):
|
||||
"""System administration commands"""
|
||||
pass
|
||||
# Set role for admin commands
|
||||
ctx.ensure_object(dict)
|
||||
ctx.parent.detected_role = 'admin'
|
||||
|
||||
|
||||
@admin.command()
|
||||
|
||||
@@ -19,9 +19,12 @@ from ..utils import output, error
|
||||
|
||||
|
||||
@click.group()
|
||||
def blockchain():
|
||||
@click.pass_context
|
||||
def blockchain(ctx):
|
||||
"""Query blockchain information and status"""
|
||||
pass
|
||||
# Set role for blockchain commands
|
||||
ctx.ensure_object(dict)
|
||||
ctx.parent.detected_role = 'blockchain'
|
||||
|
||||
|
||||
@blockchain.command()
|
||||
|
||||
@@ -9,9 +9,12 @@ from ..utils import output, error, success
|
||||
|
||||
|
||||
@click.group()
|
||||
def client():
|
||||
@click.pass_context
|
||||
def client(ctx):
|
||||
"""Submit and manage jobs"""
|
||||
pass
|
||||
# Set role for client commands
|
||||
ctx.ensure_object(dict)
|
||||
ctx.parent.detected_role = 'client'
|
||||
|
||||
|
||||
@client.command()
|
||||
|
||||
@@ -9,10 +9,18 @@ from typing import Optional, Dict, Any, List
|
||||
from ..utils import output, error, success
|
||||
|
||||
|
||||
@click.group()
|
||||
def miner():
|
||||
@click.group(invoke_without_command=True)
|
||||
@click.pass_context
|
||||
def miner(ctx):
|
||||
"""Register as miner and process jobs"""
|
||||
pass
|
||||
# Set role for miner commands - this will be used by parent context
|
||||
ctx.ensure_object(dict)
|
||||
# Set role at the highest level context (CLI root)
|
||||
ctx.find_root().detected_role = 'miner'
|
||||
|
||||
# If no subcommand was invoked, show help
|
||||
if ctx.invoked_subcommand is None:
|
||||
click.echo(ctx.get_help())
|
||||
|
||||
|
||||
@miner.command()
|
||||
|
||||
Reference in New Issue
Block a user