Skip to content

feat: Add conflict command to differentiate versioning #292

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

Merged
merged 22 commits into from
Aug 3, 2025
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
eba184b
feat: add deps and update config file
zhravan Jul 18, 2025
16a4b53
feat: register the command conflict
zhravan Jul 18, 2025
f308257
feat: add messages and test cases to handle errors | core business lo…
zhravan Jul 18, 2025
3d1e12f
feat: add all commands
zhravan Jul 18, 2025
2e7ea8b
feat: remove duplicates and refine the commands
zhravan Jul 18, 2025
5f1f047
chore: resolve conflicts
zhravan Jul 18, 2025
707951a
self-review: claenup logic and commands
zhravan Jul 18, 2025
1352f0b
test-case: refactoring and add test cases
zhravan Jul 18, 2025
754b250
self-review: use existing outputformatter
zhravan Jul 18, 2025
e0d6144
feat:review comments
zhravan Jul 26, 2025
cc2f81a
chores: address review comments
zhravan Jul 26, 2025
e9e98fe
chores: address review comments
zhravan Jul 26, 2025
7c77fa6
chores: address review comments | test cases fixed
zhravan Jul 26, 2025
7fd957e
Merge branch 'feat/cli' into feat/cli_/conflict
raghavyuva Jul 27, 2025
55830f1
Merge branch 'feat/cli' of github.com:raghavyuva/nixopus into feat/cl…
zhravan Jul 27, 2025
0c6373e
Merge branch 'feat/cli_/conflict' of github.com:shravan20/nixopus int…
zhravan Jul 27, 2025
8ed4187
chores: refactoring the code
zhravan Jul 30, 2025
986dabf
chores: update .gitignore
zhravan Jul 31, 2025
fd85279
chore: resolve conflicts
zhravan Aug 1, 2025
8721a35
chore: resolve conflicts
zhravan Aug 1, 2025
902fd85
feat: development configs and prod configs separations
zhravan Aug 3, 2025
44946e0
chores: addressed review comments
zhravan Aug 3, 2025
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
70 changes: 38 additions & 32 deletions cli/Makefile
Original file line number Diff line number Diff line change
@@ -1,54 +1,60 @@
.PHONY: help install install-dev test test-cov lint clean format check build publish dev run
.PHONY: help setup test test-cov lint clean format check build publish dev nixopus

help:
@echo "Available commands:"
help: ## Show available commands
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'

install:
poetry install
setup: ## Setup Python environment and install dependencies
@if command -v poetry >/dev/null 2>&1; then \
poetry install --with dev; \
echo "Environment ready! Use: make nixopus ARGS=\"command\""; \
else \
echo "Poetry not found. Install: curl -sSL https://install.python-poetry.org | python3 -"; \
exit 1; \
fi

install-dev:
poetry install --with dev --no-root

test:
test: ## Run tests
poetry run pytest

test-cov:
poetry run pytest --cov=core --cov=utils --cov-report=term-missing --cov-report=html

test-watch:
poetry run pytest-watch
test-cov: ## Run tests with coverage
poetry run pytest --cov=app --cov-report=term-missing --cov-report=html

lint:
lint: ## Run linting
poetry run flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
poetry run flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics

format:
format: ## Format code
poetry run black .
poetry run isort .

check:
$(MAKE) lint
$(MAKE) test

clean:
rm -rf build/
rm -rf dist/
rm -rf *.egg-info/
rm -rf .pytest_cache/
rm -rf htmlcov/
rm -rf .coverage
check: ## Run linting and tests
$(MAKE) lint && $(MAKE) test

clean: ## Clean build artifacts
rm -rf build/ dist/ *.egg-info/ .pytest_cache/ htmlcov/ .coverage
find . -type d -name __pycache__ -delete
find . -type f -name "*.pyc" -delete

build:
build: ## Build the package
poetry build

publish:
publish: ## Publish to PyPI
poetry publish

dev:
dev: ## Activate development shell
poetry shell

run:
poetry run nixopus
nixopus: ## Run nixopus CLI
@if [ -z "$(ARGS)" ]; then \
poetry run nixopus --help; \
else \
poetry run nixopus $(ARGS); \
fi

conflict: ## Run conflict command
poetry run nixopus conflict $(ARGS)

preflight: ## Run preflight command
poetry run nixopus preflight $(ARGS)

version: ## Show version
poetry run nixopus version
Empty file.
47 changes: 47 additions & 0 deletions cli/app/commands/conflict/command.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import typer
from .conflict import ConflictConfig, ConflictService
from .messages import conflict_check_help, error_checking_conflicts
from app.utils.logger import Logger

conflict_app = typer.Typer(help=conflict_check_help, no_args_is_help=False)


@conflict_app.callback(invoke_without_command=True)
def conflict_callback(
ctx: typer.Context,
config_file: str = typer.Option("helpers/config.prod.yaml", "--config-file", "-c", help="Path to configuration file"),
Copy link
Owner

Choose a reason for hiding this comment

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

use config to load this default option

timeout: int = typer.Option(5, "--timeout", "-t", help="Timeout for tool checks in seconds"),
verbose: bool = typer.Option(False, "--verbose", "-v", help="Verbose output"),
output: str = typer.Option("text", "--output", "-o", help="Output format (text/json)"),
) -> None:
"""Check for tool version conflicts"""
if ctx.invoked_subcommand is None:
try:
logger = Logger(verbose=verbose)

config = ConflictConfig(
Copy link
Owner

Choose a reason for hiding this comment

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

make use of the timeout wrapper here like other commands instead of passing the timeout variable

config_file=config_file,
timeout=timeout,
verbose=verbose,
output=output,
)

service = ConflictService(config, logger=logger)
result = service.check_and_format(output)

# Check if there are any conflicts and exit with appropriate code
results = service.check_conflicts()
conflicts = [r for r in results if r.conflict]

if conflicts:
logger.error(result)
logger.warning(f"Found {len(conflicts)} version conflict(s)")
raise typer.Exit(1)
else:
logger.success(result)
logger.info("No version conflicts found")

except Exception as e:
logger = Logger(verbose=verbose)
logger.error(error_checking_conflicts.format(error=str(e)))
raise typer.Exit(1)
Loading
Loading