Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
17 changes: 17 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# SystemLink Function Services Configuration
# These environment variables can be set in this .env file for local development

# Unified Function Management Service URL (definitions + executions)
# FUNCTION_SERVICE_URL=http://localhost:8080

# Legacy separate execution service URL is no longer used:
# (FUNCTION_EXECUTION_SERVICE_URL has been deprecated)

# Or specify a common base URL used to derive the unified service path
# SYSTEMLINK_API_URL=http://localhost:8080

# API Key for authentication
# SYSTEMLINK_API_KEY=your_api_key_here

# SSL Verification (set to false for local development with self-signed certificates)
# SLCLI_SSL_VERIFY=false
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,4 @@ tests/unit/__pycache__/

# E2E test configuration
tests/e2e/e2e_config.json
.env
578 changes: 578 additions & 0 deletions README.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion slcli/_version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Version information for slcli."""

# This file is auto-generated. Do not edit manually.
# This file is auto-generated during build. Do not edit manually.
__version__ = "0.7.5"
81 changes: 81 additions & 0 deletions slcli/config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
"""Configuration management for slcli."""

import json
import os
from pathlib import Path
from typing import Dict, Optional


def get_config_file_path() -> Path:
"""Get the path to the slcli configuration file."""
# Use XDG_CONFIG_HOME if set, otherwise use ~/.config
if "XDG_CONFIG_HOME" in os.environ:
config_dir = Path(os.environ["XDG_CONFIG_HOME"]) / "slcli"
else:
config_dir = Path.home() / ".config" / "slcli"

config_dir.mkdir(parents=True, exist_ok=True)
return config_dir / "config.json"


def load_config() -> Dict[str, str]:
"""Load configuration from the config file.

Returns:
Dictionary containing configuration values
"""
config_file = get_config_file_path()

if not config_file.exists():
return {}

try:
with open(config_file, "r", encoding="utf-8") as f:
return json.load(f)
except (json.JSONDecodeError, OSError):
# If config file is corrupted or unreadable, return empty config
return {}


def save_config(config: Dict[str, str]) -> None:
"""Save configuration to the config file.

Args:
config: Dictionary containing configuration values to save
"""
config_file = get_config_file_path()

try:
with open(config_file, "w", encoding="utf-8") as f:
json.dump(config, f, indent=2)
except OSError as e:
raise RuntimeError(f"Failed to save configuration: {e}")


def get_function_service_url() -> Optional[str]:
"""Get the configured URL for the Function Service.

Returns:
The configured function service URL, or None if not configured
"""
config = load_config()
return config.get("function_service_url")


def set_function_service_url(url: str) -> None:
"""Set the URL for the Function Service.

Args:
url: The URL to use for function commands
"""
config = load_config()
config["function_service_url"] = url
save_config(config)


def remove_function_service_url() -> None:
"""Remove the configured Function Service URL."""
config = load_config()
if "function_service_url" in config:
del config["function_service_url"]
save_config(config)
Loading