Skip to content

Commit fed5963

Browse files
committed
feat: 重构项目结构以支持多语言实现
将Python源代码移动到evm/python目录 新增C语言实现目录evm/c 更新所有导入路径以匹配新结构 添加evm/__init__.py用于正确导出包 添加evm/python/__main__.py支持模块执行
1 parent 6ce6ea6 commit fed5963

31 files changed

Lines changed: 2571 additions & 25 deletions

Makefile

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -43,46 +43,46 @@ format: ## Format code with black
4343

4444
run: ## Run EVM with example commands
4545
@echo "Setting up example environment..."
46-
python -m evm.main set NODE_ENV development
47-
python -m evm.main set API_URL http://localhost:3000
48-
python -m evm.main set DEBUG true
46+
python -m evm.python set NODE_ENV development
47+
python -m evm.python set API_URL http://localhost:3000
48+
python -m evm.python set DEBUG true
4949
@echo ""
5050
@echo "Listing environment variables:"
51-
python -m evm.main list
51+
python -m evm.python list
5252
@echo ""
5353
@echo "Running example complete!"
5454

5555
demo: ## Run a full demo of EVM features
5656
@echo "=== EVM Demo ==="
5757
@echo ""
5858
@echo "1. Setting environment variables..."
59-
python -m evm.main set APP_NAME "EVM Demo"
60-
python -m evm.main set APP_VERSION "1.0.0"
61-
python -m evm.main set ENVIRONMENT "development"
59+
python -m evm.python set APP_NAME "EVM Demo"
60+
python -m evm.python set APP_VERSION "1.0.0"
61+
python -m evm.python set ENVIRONMENT "development"
6262
@echo ""
6363
@echo "2. Listing all variables:"
64-
python -m evm.main list
64+
python -m evm.python list
6565
@echo ""
6666
@echo "3. Getting a specific variable:"
67-
python -m evm.main get APP_NAME
67+
python -m evm.python get APP_NAME
6868
@echo ""
6969
@echo "4. Searching for 'APP':"
70-
python -m evm.main search APP
70+
python -m evm.python search APP
7171
@echo ""
7272
@echo "5. Exporting to .env format:"
73-
python -m evm.main export --format env
73+
python -m evm.python export --format env
7474
@echo ""
7575
@echo "6. Creating backup:"
76-
python -m evm.main backup
76+
python -m evm.python backup
7777
@echo ""
7878
@echo "7. Renaming variable:"
79-
python -m evm.main rename ENVIRONMENT ENV
79+
python -m evm.python rename ENVIRONMENT ENV
8080
@echo ""
8181
@echo "8. Copying variable:"
82-
python -m evm.main copy APP_NAME APP
82+
python -m evm.python copy APP_NAME APP
8383
@echo ""
8484
@echo "9. Final list:"
85-
python -m evm.main list
85+
python -m evm.python list
8686
@echo ""
8787
@echo "=== Demo Complete ==="
8888

docs/CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,20 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [1.5.0] - 2025-02-07
9+
10+
### Changed
11+
- **Project Structure Reorganization**: Restructured codebase for multi-language support
12+
- Moved Python source code to `evm/python/` directory
13+
- Created `evm/c/` directory for future C implementation
14+
- Updated all import paths to reflect new structure
15+
- Added `evm/__init__.py` for proper package exports
16+
- Added `evm/python/__main__.py` for module execution support
17+
18+
### Fixed
19+
- Fixed search functionality to handle non-string values correctly
20+
- Updated all version references from 1.4.0 to 1.5.0
21+
822
## [1.6.0] - 2024-01-06
923

1024
### Added

evm/__init__.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
"""
2-
Environment Variable Manager (EVM)
3-
A command-line tool for managing environment variables.
2+
EVM - Environment Variable Manager
3+
Environment variable management tool with both Python and C implementations.
44
"""
55

6-
__version__ = "1.4.0"
7-
__author__ = "EVM Tool"
6+
from evm.python import __version__, __author__
7+
8+
__all__ = ['__version__', '__author__']

evm/c/Makefile

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
# EVM C Implementation Makefile
2+
# Supports: macOS, Linux
3+
4+
CC = gcc
5+
CFLAGS = -Wall -Wextra -O2 -std=c99 -D_GNU_SOURCE
6+
LDFLAGS =
7+
TARGET = evm
8+
9+
# Source files
10+
SOURCES = main.c core.c utils.c list.c io.c group.c
11+
OBJECTS = $(SOURCES:.c=.o)
12+
13+
# Default target
14+
all: $(TARGET)
15+
16+
# Build target
17+
$(TARGET): $(OBJECTS)
18+
$(CC) $(OBJECTS) -o $(TARGET) $(LDFLAGS)
19+
@echo "Build complete: $(TARGET)"
20+
21+
# Compile source files
22+
%.o: %.c evm.h
23+
$(CC) $(CFLAGS) -c $< -o $@
24+
25+
# Clean build files
26+
clean:
27+
rm -f $(OBJECTS) $(TARGET)
28+
rm -rf evm-cli-macos evm-cli-macos.tar.gz
29+
@echo "Clean complete"
30+
31+
# Install locally (development)
32+
install-local: $(TARGET)
33+
cp $(TARGET) /usr/local/bin/
34+
chmod +x /usr/local/bin/$(TARGET)
35+
@echo "Installed to /usr/local/bin/$(TARGET)"
36+
37+
# Uninstall
38+
uninstall:
39+
rm -f /usr/local/bin/$(TARGET)
40+
@echo "Uninstalled $(TARGET)"
41+
42+
# Create macOS distribution package
43+
dist-macos: $(TARGET)
44+
@echo "Creating macOS distribution package..."
45+
mkdir -p evm-cli-macos
46+
cp $(TARGET) evm-cli-macos/
47+
cp ../../README.md evm-cli-macos/ 2>/dev/null || echo "README.md not found"
48+
cp ../../LICENSE evm-cli-macos/ 2>/dev/null || echo "LICENSE not found"
49+
cp ../../QUICKSTART.md evm-cli-macos/ 2>/dev/null || echo "QUICKSTART.md not found"
50+
51+
@echo '#!/bin/bash' > evm-cli-macos/install.sh
52+
@echo '# EVM macOS Installation Script' >> evm-cli-macos/install.sh
53+
@echo 'set -e' >> evm-cli-macos/install.sh
54+
@echo '' >> evm-cli-macos/install.sh
55+
@echo 'echo "Installing EVM..."' >> evm-cli-macos/install.sh
56+
@echo 'INSTALL_DIR="/usr/local/bin"' >> evm-cli-macos/install.sh
57+
@echo '' >> evm-cli-macos/install.sh
58+
@echo 'if [[ ! -w "$$INSTALL_DIR" ]]; then' >> evm-cli-macos/install.sh
59+
@echo ' echo "需要管理员权限来安装到 $$INSTALL_DIR"' >> evm-cli-macos/install.sh
60+
@echo ' sudo cp evm "$$INSTALL_DIR/"' >> evm-cli-macos/install.sh
61+
@echo ' sudo chmod +x "$$INSTALL_DIR/evm"' >> evm-cli-macos/install.sh
62+
@echo 'else' >> evm-cli-macos/install.sh
63+
@echo ' cp evm "$$INSTALL_DIR/"' >> evm-cli-macos/install.sh
64+
@echo ' chmod +x "$$INSTALL_DIR/evm"' >> evm-cli-macos/install.sh
65+
@echo 'fi' >> evm-cli-macos/install.sh
66+
@echo '' >> evm-cli-macos/install.sh
67+
@echo 'echo "✓ EVM 安装成功!"' >> evm-cli-macos/install.sh
68+
@echo 'echo ""' >> evm-cli-macos/install.sh
69+
@echo 'echo "运行 'evm --help' 开始使用"' >> evm-cli-macos/install.sh
70+
71+
chmod +x evm-cli-macos/install.sh
72+
chmod +x evm-cli-macos/$(TARGET)
73+
74+
tar -czf evm-cli-macos.tar.gz evm-cli-macos
75+
@echo "Distribution package created: evm-cli-macos.tar.gz"
76+
77+
# Debug build
78+
debug: CFLAGS = -Wall -Wextra -g -O0 -std=c99 -D_GNU_SOURCE
79+
debug: clean $(TARGET)
80+
81+
# Run tests
82+
test: $(TARGET)
83+
./$(TARGET) --version
84+
./$(TARGET) set TEST_VAR "hello world"
85+
./$(TARGET) get TEST_VAR
86+
./$(TARGET) list
87+
./$(TARGET) delete TEST_VAR
88+
@echo "Basic tests passed!"
89+
90+
.PHONY: all clean install-local uninstall dist-macos debug test

0 commit comments

Comments
 (0)