article-cli 1.0.3__tar.gz → 1.1.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {article_cli-1.0.3 → article_cli-1.1.1}/PKG-INFO +86 -3
- {article_cli-1.0.3 → article_cli-1.1.1}/README.md +85 -2
- {article_cli-1.0.3 → article_cli-1.1.1}/pyproject.toml +1 -1
- {article_cli-1.0.3 → article_cli-1.1.1}/src/article_cli/__init__.py +11 -2
- {article_cli-1.0.3 → article_cli-1.1.1}/src/article_cli/cli.py +175 -1
- {article_cli-1.0.3 → article_cli-1.1.1}/src/article_cli/config.py +12 -0
- article_cli-1.1.1/src/article_cli/latex_compiler.py +368 -0
- article_cli-1.1.1/src/article_cli/repository_setup.py +1131 -0
- {article_cli-1.0.3 → article_cli-1.1.1}/.gitignore +0 -0
- {article_cli-1.0.3 → article_cli-1.1.1}/LICENSE +0 -0
- {article_cli-1.0.3 → article_cli-1.1.1}/src/article_cli/__main__.py +0 -0
- {article_cli-1.0.3 → article_cli-1.1.1}/src/article_cli/git_manager.py +0 -0
- {article_cli-1.0.3 → article_cli-1.1.1}/src/article_cli/zotero.py +0 -0
- {article_cli-1.0.3 → article_cli-1.1.1}/tests/__init__.py +0 -0
- {article_cli-1.0.3 → article_cli-1.1.1}/tests/test_config.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: article-cli
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.1.1
|
|
4
4
|
Summary: CLI tool for managing LaTeX articles with git integration and Zotero bibliography
|
|
5
5
|
Project-URL: Homepage, https://github.com/feelpp/article.cli
|
|
6
6
|
Project-URL: Documentation, https://github.com/feelpp/article.cli#readme
|
|
@@ -63,11 +63,15 @@ A command-line tool for managing LaTeX articles with git integration and Zotero
|
|
|
63
63
|
|
|
64
64
|
## Features
|
|
65
65
|
|
|
66
|
+
- **Repository Initialization**: Complete setup for LaTeX article projects with one command
|
|
67
|
+
- **LaTeX Compilation**: Compile documents with latexmk/pdflatex, watch mode, shell escape support
|
|
68
|
+
- **GitHub Actions Workflows**: Automated PDF compilation, artifact upload, and GitHub releases
|
|
66
69
|
- **Git Release Management**: Create, list, and delete releases with gitinfo2 support
|
|
67
70
|
- **Zotero Integration**: Synchronize bibliography from Zotero with robust pagination and error handling
|
|
68
71
|
- **LaTeX Build Management**: Clean build files and manage LaTeX compilation artifacts
|
|
69
72
|
- **Git Hooks Setup**: Automated setup of git hooks for gitinfo2 integration
|
|
70
|
-
- **
|
|
73
|
+
- **Project Configuration**: Auto-generates pyproject.toml with article-cli settings
|
|
74
|
+
- **Documentation**: Creates README with build instructions and usage guide
|
|
71
75
|
|
|
72
76
|
## Installation
|
|
73
77
|
|
|
@@ -87,12 +91,43 @@ pip install -e .
|
|
|
87
91
|
|
|
88
92
|
## Quick Start
|
|
89
93
|
|
|
94
|
+
### For New Projects
|
|
95
|
+
|
|
96
|
+
1. **Initialize your LaTeX article repository**:
|
|
97
|
+
```bash
|
|
98
|
+
cd your-article-repo
|
|
99
|
+
article-cli init --title "Your Article Title" --authors "Author One,Author Two"
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
This creates:
|
|
103
|
+
- `.github/workflows/latex.yml` - Complete CI/CD pipeline
|
|
104
|
+
- `pyproject.toml` - Project configuration with article-cli settings
|
|
105
|
+
- `README.md` - Documentation and usage instructions
|
|
106
|
+
- `.gitignore` - LaTeX-specific ignore rules
|
|
107
|
+
- `.vscode/settings.json` - LaTeX Workshop configuration
|
|
108
|
+
- `.vscode/ltex.dictionary.en-US.txt` - Custom dictionary
|
|
109
|
+
|
|
110
|
+
2. **Configure Zotero** (add as GitHub secret):
|
|
111
|
+
```bash
|
|
112
|
+
export ZOTERO_API_KEY="your_api_key_here"
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
3. **Setup git hooks and update bibliography**:
|
|
116
|
+
```bash
|
|
117
|
+
article-cli setup
|
|
118
|
+
article-cli update-bibtex
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
4. **Commit and push** to trigger automated PDF compilation!
|
|
122
|
+
|
|
123
|
+
### For Existing Projects
|
|
124
|
+
|
|
90
125
|
1. **Setup git hooks** (run once per repository):
|
|
91
126
|
```bash
|
|
92
127
|
article-cli setup
|
|
93
128
|
```
|
|
94
129
|
|
|
95
|
-
2. **Configure Zotero credentials
|
|
130
|
+
2. **Configure Zotero credentials**:
|
|
96
131
|
```bash
|
|
97
132
|
export ZOTERO_API_KEY="your_api_key_here"
|
|
98
133
|
export ZOTERO_GROUP_ID="your_group_id" # or ZOTERO_USER_ID
|
|
@@ -137,6 +172,29 @@ clean_extensions = [".aux", ".bbl", ".blg", ".log", ".out", ".synctex.gz"]
|
|
|
137
172
|
|
|
138
173
|
## Usage
|
|
139
174
|
|
|
175
|
+
### Repository Initialization
|
|
176
|
+
|
|
177
|
+
```bash
|
|
178
|
+
# Initialize a new article repository (auto-detects main .tex file)
|
|
179
|
+
article-cli init --title "My Article Title" --authors "John Doe,Jane Smith"
|
|
180
|
+
|
|
181
|
+
# Specify custom Zotero group ID
|
|
182
|
+
article-cli init --title "My Article" --authors "Author" --group-id 1234567
|
|
183
|
+
|
|
184
|
+
# Specify main .tex file explicitly
|
|
185
|
+
article-cli init --title "My Article" --authors "Author" --tex-file article.tex
|
|
186
|
+
|
|
187
|
+
# Force overwrite existing files
|
|
188
|
+
article-cli init --title "My Article" --authors "Author" --force
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
The `init` command sets up:
|
|
192
|
+
- **GitHub Actions workflow** for automated PDF compilation and releases
|
|
193
|
+
- **pyproject.toml** with dependencies and article-cli configuration
|
|
194
|
+
- **README.md** with comprehensive documentation
|
|
195
|
+
- **.gitignore** with LaTeX-specific patterns
|
|
196
|
+
- **VS Code configuration** for LaTeX Workshop with auto-build and SyncTeX
|
|
197
|
+
|
|
140
198
|
### Git Release Management
|
|
141
199
|
|
|
142
200
|
```bash
|
|
@@ -163,6 +221,31 @@ article-cli update-bibtex --output my-refs.bib
|
|
|
163
221
|
article-cli update-bibtex --no-backup
|
|
164
222
|
```
|
|
165
223
|
|
|
224
|
+
### LaTeX Compilation
|
|
225
|
+
|
|
226
|
+
```bash
|
|
227
|
+
# Compile with latexmk (default engine)
|
|
228
|
+
article-cli compile
|
|
229
|
+
|
|
230
|
+
# Compile specific file with latexmk
|
|
231
|
+
article-cli compile main.tex
|
|
232
|
+
|
|
233
|
+
# Compile with pdflatex engine
|
|
234
|
+
article-cli compile --engine pdflatex
|
|
235
|
+
|
|
236
|
+
# Enable shell escape (for code highlighting, etc.)
|
|
237
|
+
article-cli compile --shell-escape
|
|
238
|
+
|
|
239
|
+
# Watch for changes and auto-recompile
|
|
240
|
+
article-cli compile --watch
|
|
241
|
+
|
|
242
|
+
# Clean before and after compilation
|
|
243
|
+
article-cli compile --clean-first --clean-after
|
|
244
|
+
|
|
245
|
+
# Specify output directory
|
|
246
|
+
article-cli compile --output-dir build/
|
|
247
|
+
```
|
|
248
|
+
|
|
166
249
|
### Project Setup
|
|
167
250
|
|
|
168
251
|
```bash
|
|
@@ -8,11 +8,15 @@ A command-line tool for managing LaTeX articles with git integration and Zotero
|
|
|
8
8
|
|
|
9
9
|
## Features
|
|
10
10
|
|
|
11
|
+
- **Repository Initialization**: Complete setup for LaTeX article projects with one command
|
|
12
|
+
- **LaTeX Compilation**: Compile documents with latexmk/pdflatex, watch mode, shell escape support
|
|
13
|
+
- **GitHub Actions Workflows**: Automated PDF compilation, artifact upload, and GitHub releases
|
|
11
14
|
- **Git Release Management**: Create, list, and delete releases with gitinfo2 support
|
|
12
15
|
- **Zotero Integration**: Synchronize bibliography from Zotero with robust pagination and error handling
|
|
13
16
|
- **LaTeX Build Management**: Clean build files and manage LaTeX compilation artifacts
|
|
14
17
|
- **Git Hooks Setup**: Automated setup of git hooks for gitinfo2 integration
|
|
15
|
-
- **
|
|
18
|
+
- **Project Configuration**: Auto-generates pyproject.toml with article-cli settings
|
|
19
|
+
- **Documentation**: Creates README with build instructions and usage guide
|
|
16
20
|
|
|
17
21
|
## Installation
|
|
18
22
|
|
|
@@ -32,12 +36,43 @@ pip install -e .
|
|
|
32
36
|
|
|
33
37
|
## Quick Start
|
|
34
38
|
|
|
39
|
+
### For New Projects
|
|
40
|
+
|
|
41
|
+
1. **Initialize your LaTeX article repository**:
|
|
42
|
+
```bash
|
|
43
|
+
cd your-article-repo
|
|
44
|
+
article-cli init --title "Your Article Title" --authors "Author One,Author Two"
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
This creates:
|
|
48
|
+
- `.github/workflows/latex.yml` - Complete CI/CD pipeline
|
|
49
|
+
- `pyproject.toml` - Project configuration with article-cli settings
|
|
50
|
+
- `README.md` - Documentation and usage instructions
|
|
51
|
+
- `.gitignore` - LaTeX-specific ignore rules
|
|
52
|
+
- `.vscode/settings.json` - LaTeX Workshop configuration
|
|
53
|
+
- `.vscode/ltex.dictionary.en-US.txt` - Custom dictionary
|
|
54
|
+
|
|
55
|
+
2. **Configure Zotero** (add as GitHub secret):
|
|
56
|
+
```bash
|
|
57
|
+
export ZOTERO_API_KEY="your_api_key_here"
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
3. **Setup git hooks and update bibliography**:
|
|
61
|
+
```bash
|
|
62
|
+
article-cli setup
|
|
63
|
+
article-cli update-bibtex
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
4. **Commit and push** to trigger automated PDF compilation!
|
|
67
|
+
|
|
68
|
+
### For Existing Projects
|
|
69
|
+
|
|
35
70
|
1. **Setup git hooks** (run once per repository):
|
|
36
71
|
```bash
|
|
37
72
|
article-cli setup
|
|
38
73
|
```
|
|
39
74
|
|
|
40
|
-
2. **Configure Zotero credentials
|
|
75
|
+
2. **Configure Zotero credentials**:
|
|
41
76
|
```bash
|
|
42
77
|
export ZOTERO_API_KEY="your_api_key_here"
|
|
43
78
|
export ZOTERO_GROUP_ID="your_group_id" # or ZOTERO_USER_ID
|
|
@@ -82,6 +117,29 @@ clean_extensions = [".aux", ".bbl", ".blg", ".log", ".out", ".synctex.gz"]
|
|
|
82
117
|
|
|
83
118
|
## Usage
|
|
84
119
|
|
|
120
|
+
### Repository Initialization
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
# Initialize a new article repository (auto-detects main .tex file)
|
|
124
|
+
article-cli init --title "My Article Title" --authors "John Doe,Jane Smith"
|
|
125
|
+
|
|
126
|
+
# Specify custom Zotero group ID
|
|
127
|
+
article-cli init --title "My Article" --authors "Author" --group-id 1234567
|
|
128
|
+
|
|
129
|
+
# Specify main .tex file explicitly
|
|
130
|
+
article-cli init --title "My Article" --authors "Author" --tex-file article.tex
|
|
131
|
+
|
|
132
|
+
# Force overwrite existing files
|
|
133
|
+
article-cli init --title "My Article" --authors "Author" --force
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
The `init` command sets up:
|
|
137
|
+
- **GitHub Actions workflow** for automated PDF compilation and releases
|
|
138
|
+
- **pyproject.toml** with dependencies and article-cli configuration
|
|
139
|
+
- **README.md** with comprehensive documentation
|
|
140
|
+
- **.gitignore** with LaTeX-specific patterns
|
|
141
|
+
- **VS Code configuration** for LaTeX Workshop with auto-build and SyncTeX
|
|
142
|
+
|
|
85
143
|
### Git Release Management
|
|
86
144
|
|
|
87
145
|
```bash
|
|
@@ -108,6 +166,31 @@ article-cli update-bibtex --output my-refs.bib
|
|
|
108
166
|
article-cli update-bibtex --no-backup
|
|
109
167
|
```
|
|
110
168
|
|
|
169
|
+
### LaTeX Compilation
|
|
170
|
+
|
|
171
|
+
```bash
|
|
172
|
+
# Compile with latexmk (default engine)
|
|
173
|
+
article-cli compile
|
|
174
|
+
|
|
175
|
+
# Compile specific file with latexmk
|
|
176
|
+
article-cli compile main.tex
|
|
177
|
+
|
|
178
|
+
# Compile with pdflatex engine
|
|
179
|
+
article-cli compile --engine pdflatex
|
|
180
|
+
|
|
181
|
+
# Enable shell escape (for code highlighting, etc.)
|
|
182
|
+
article-cli compile --shell-escape
|
|
183
|
+
|
|
184
|
+
# Watch for changes and auto-recompile
|
|
185
|
+
article-cli compile --watch
|
|
186
|
+
|
|
187
|
+
# Clean before and after compilation
|
|
188
|
+
article-cli compile --clean-first --clean-after
|
|
189
|
+
|
|
190
|
+
# Specify output directory
|
|
191
|
+
article-cli compile --output-dir build/
|
|
192
|
+
```
|
|
193
|
+
|
|
111
194
|
### Project Setup
|
|
112
195
|
|
|
113
196
|
```bash
|
|
@@ -8,7 +8,7 @@ This package provides tools for:
|
|
|
8
8
|
- Git hooks setup
|
|
9
9
|
"""
|
|
10
10
|
|
|
11
|
-
__version__ = "1.
|
|
11
|
+
__version__ = "1.1.1"
|
|
12
12
|
__author__ = "Christophe Prud'homme"
|
|
13
13
|
__email__ = "prudhomm@cemosis.fr"
|
|
14
14
|
|
|
@@ -16,5 +16,14 @@ from .cli import main
|
|
|
16
16
|
from .config import Config
|
|
17
17
|
from .zotero import ZoteroBibTexUpdater
|
|
18
18
|
from .git_manager import GitManager
|
|
19
|
+
from .repository_setup import RepositorySetup
|
|
20
|
+
from .latex_compiler import LaTeXCompiler
|
|
19
21
|
|
|
20
|
-
__all__ = [
|
|
22
|
+
__all__ = [
|
|
23
|
+
"main",
|
|
24
|
+
"Config",
|
|
25
|
+
"ZoteroBibTexUpdater",
|
|
26
|
+
"GitManager",
|
|
27
|
+
"RepositorySetup",
|
|
28
|
+
"LaTeXCompiler",
|
|
29
|
+
]
|
|
@@ -13,6 +13,7 @@ from . import __version__
|
|
|
13
13
|
from .config import Config
|
|
14
14
|
from .zotero import ZoteroBibTexUpdater, print_error, print_info
|
|
15
15
|
from .git_manager import GitManager
|
|
16
|
+
from .repository_setup import RepositorySetup
|
|
16
17
|
|
|
17
18
|
|
|
18
19
|
def create_parser() -> argparse.ArgumentParser:
|
|
@@ -23,8 +24,13 @@ def create_parser() -> argparse.ArgumentParser:
|
|
|
23
24
|
formatter_class=argparse.RawDescriptionHelpFormatter,
|
|
24
25
|
epilog="""
|
|
25
26
|
Examples:
|
|
27
|
+
%(prog)s init --title "My Article" --authors "John Doe,Jane Smith"
|
|
26
28
|
%(prog)s setup # Setup git hooks
|
|
27
29
|
%(prog)s clean # Clean build files
|
|
30
|
+
%(prog)s compile main.tex # Compile with latexmk
|
|
31
|
+
%(prog)s compile --engine pdflatex # Compile with pdflatex
|
|
32
|
+
%(prog)s compile --shell-escape # Enable shell escape
|
|
33
|
+
%(prog)s compile --watch # Watch and auto-recompile
|
|
28
34
|
%(prog)s create v1.0.0 # Create release v1.0.0
|
|
29
35
|
%(prog)s list --count 10 # List 10 recent releases
|
|
30
36
|
%(prog)s delete v1.0.0 # Delete release
|
|
@@ -46,12 +52,74 @@ Environment variables:
|
|
|
46
52
|
|
|
47
53
|
subparsers = parser.add_subparsers(dest="command", help="Command to execute")
|
|
48
54
|
|
|
55
|
+
# Init command
|
|
56
|
+
init_parser = subparsers.add_parser(
|
|
57
|
+
"init", help="Initialize repository with workflows and configuration"
|
|
58
|
+
)
|
|
59
|
+
init_parser.add_argument("--title", required=True, help="Article title")
|
|
60
|
+
init_parser.add_argument(
|
|
61
|
+
"--authors",
|
|
62
|
+
required=True,
|
|
63
|
+
help='Comma-separated list of authors (e.g., "John Doe,Jane Smith")',
|
|
64
|
+
)
|
|
65
|
+
init_parser.add_argument(
|
|
66
|
+
"--group-id",
|
|
67
|
+
default="4678293",
|
|
68
|
+
help="Zotero group ID (default: 4678293 for article.template)",
|
|
69
|
+
)
|
|
70
|
+
init_parser.add_argument(
|
|
71
|
+
"--tex-file",
|
|
72
|
+
help="Main .tex file (auto-detected if not specified)",
|
|
73
|
+
)
|
|
74
|
+
init_parser.add_argument(
|
|
75
|
+
"--force",
|
|
76
|
+
action="store_true",
|
|
77
|
+
help="Overwrite existing files",
|
|
78
|
+
)
|
|
79
|
+
|
|
49
80
|
# Setup command
|
|
50
81
|
subparsers.add_parser("setup", help="Setup git hooks for gitinfo2")
|
|
51
82
|
|
|
52
83
|
# Clean command
|
|
53
84
|
subparsers.add_parser("clean", help="Clean LaTeX build files")
|
|
54
85
|
|
|
86
|
+
# Compile command
|
|
87
|
+
compile_parser = subparsers.add_parser(
|
|
88
|
+
"compile", help="Compile LaTeX document using latexmk"
|
|
89
|
+
)
|
|
90
|
+
compile_parser.add_argument(
|
|
91
|
+
"tex_file",
|
|
92
|
+
nargs="?",
|
|
93
|
+
help="LaTeX file to compile (auto-detected if not specified)",
|
|
94
|
+
)
|
|
95
|
+
compile_parser.add_argument(
|
|
96
|
+
"--engine",
|
|
97
|
+
choices=["latexmk", "pdflatex"],
|
|
98
|
+
default="latexmk",
|
|
99
|
+
help="LaTeX engine to use (default: latexmk)",
|
|
100
|
+
)
|
|
101
|
+
compile_parser.add_argument(
|
|
102
|
+
"--shell-escape",
|
|
103
|
+
action="store_true",
|
|
104
|
+
help="Enable shell escape (for code highlighting, etc.)",
|
|
105
|
+
)
|
|
106
|
+
compile_parser.add_argument(
|
|
107
|
+
"--clean-first",
|
|
108
|
+
action="store_true",
|
|
109
|
+
help="Clean build files before compilation",
|
|
110
|
+
)
|
|
111
|
+
compile_parser.add_argument(
|
|
112
|
+
"--clean-after", action="store_true", help="Clean build files after compilation"
|
|
113
|
+
)
|
|
114
|
+
compile_parser.add_argument(
|
|
115
|
+
"--watch",
|
|
116
|
+
action="store_true",
|
|
117
|
+
help="Watch for changes and recompile automatically",
|
|
118
|
+
)
|
|
119
|
+
compile_parser.add_argument(
|
|
120
|
+
"--output-dir", help="Output directory for compiled files"
|
|
121
|
+
)
|
|
122
|
+
|
|
55
123
|
# Create command
|
|
56
124
|
create_parser = subparsers.add_parser("create", help="Create a new release")
|
|
57
125
|
create_parser.add_argument("version", help="Version tag (e.g., v1.0.0)")
|
|
@@ -102,6 +170,29 @@ Environment variables:
|
|
|
102
170
|
return parser
|
|
103
171
|
|
|
104
172
|
|
|
173
|
+
def handle_init_command(args: argparse.Namespace, config: Config) -> int:
|
|
174
|
+
"""Handle the init command"""
|
|
175
|
+
try:
|
|
176
|
+
# Parse comma-separated authors
|
|
177
|
+
authors = [a.strip() for a in args.authors.split(",")]
|
|
178
|
+
|
|
179
|
+
repo_setup = RepositorySetup()
|
|
180
|
+
return (
|
|
181
|
+
0
|
|
182
|
+
if repo_setup.init_repository(
|
|
183
|
+
title=args.title,
|
|
184
|
+
authors=authors,
|
|
185
|
+
group_id=args.group_id,
|
|
186
|
+
force=args.force,
|
|
187
|
+
main_tex_file=args.tex_file,
|
|
188
|
+
)
|
|
189
|
+
else 1
|
|
190
|
+
)
|
|
191
|
+
except Exception as e:
|
|
192
|
+
print_error(f"Failed to initialize repository: {e}")
|
|
193
|
+
return 1
|
|
194
|
+
|
|
195
|
+
|
|
105
196
|
def handle_setup_command(config: Config) -> int:
|
|
106
197
|
"""Handle the setup command"""
|
|
107
198
|
try:
|
|
@@ -125,6 +216,80 @@ def handle_clean_command(config: Config) -> int:
|
|
|
125
216
|
return 1
|
|
126
217
|
|
|
127
218
|
|
|
219
|
+
def handle_compile_command(args: argparse.Namespace, config: Config) -> int:
|
|
220
|
+
"""Handle the compile command"""
|
|
221
|
+
try:
|
|
222
|
+
from .latex_compiler import LaTeXCompiler
|
|
223
|
+
|
|
224
|
+
# Auto-detect tex file if not provided
|
|
225
|
+
tex_file = args.tex_file
|
|
226
|
+
if not tex_file:
|
|
227
|
+
tex_file = _auto_detect_tex_file()
|
|
228
|
+
if not tex_file:
|
|
229
|
+
print_error(
|
|
230
|
+
"No .tex file specified and none found in current directory"
|
|
231
|
+
)
|
|
232
|
+
return 1
|
|
233
|
+
|
|
234
|
+
# Validate tex file exists
|
|
235
|
+
tex_path = Path(tex_file)
|
|
236
|
+
if not tex_path.exists():
|
|
237
|
+
print_error(f"LaTeX file not found: {tex_file}")
|
|
238
|
+
return 1
|
|
239
|
+
|
|
240
|
+
compiler = LaTeXCompiler(config)
|
|
241
|
+
|
|
242
|
+
# Clean before compilation if requested
|
|
243
|
+
if args.clean_first:
|
|
244
|
+
print_info("Cleaning build files before compilation...")
|
|
245
|
+
git_manager = GitManager()
|
|
246
|
+
latex_config = config.get_latex_config()
|
|
247
|
+
git_manager.clean_latex_files(latex_config["clean_extensions"])
|
|
248
|
+
|
|
249
|
+
# Compile the document
|
|
250
|
+
success = compiler.compile(
|
|
251
|
+
tex_file=tex_file,
|
|
252
|
+
engine=args.engine,
|
|
253
|
+
shell_escape=args.shell_escape,
|
|
254
|
+
output_dir=args.output_dir,
|
|
255
|
+
watch=args.watch,
|
|
256
|
+
)
|
|
257
|
+
|
|
258
|
+
# Clean after compilation if requested
|
|
259
|
+
if args.clean_after and success:
|
|
260
|
+
print_info("Cleaning build files after compilation...")
|
|
261
|
+
git_manager = GitManager()
|
|
262
|
+
latex_config = config.get_latex_config()
|
|
263
|
+
git_manager.clean_latex_files(latex_config["clean_extensions"])
|
|
264
|
+
|
|
265
|
+
return 0 if success else 1
|
|
266
|
+
|
|
267
|
+
except Exception as e:
|
|
268
|
+
print_error(f"Compilation failed: {e}")
|
|
269
|
+
return 1
|
|
270
|
+
|
|
271
|
+
|
|
272
|
+
def _auto_detect_tex_file() -> Optional[str]:
|
|
273
|
+
"""Auto-detect main .tex file in current directory"""
|
|
274
|
+
current_dir = Path.cwd()
|
|
275
|
+
tex_files = list(current_dir.glob("*.tex"))
|
|
276
|
+
|
|
277
|
+
if not tex_files:
|
|
278
|
+
return None
|
|
279
|
+
|
|
280
|
+
if len(tex_files) == 1:
|
|
281
|
+
return tex_files[0].name
|
|
282
|
+
|
|
283
|
+
# Multiple .tex files - prefer common patterns
|
|
284
|
+
for pattern in ["main.tex", "article.tex", f"{current_dir.name}.tex"]:
|
|
285
|
+
if (current_dir / pattern).exists():
|
|
286
|
+
return pattern
|
|
287
|
+
|
|
288
|
+
# Return first .tex file found
|
|
289
|
+
print_info(f"Multiple .tex files found, using: {tex_files[0].name}")
|
|
290
|
+
return tex_files[0].name
|
|
291
|
+
|
|
292
|
+
|
|
128
293
|
def handle_create_command(args: argparse.Namespace, config: Config) -> int:
|
|
129
294
|
"""Handle the create command"""
|
|
130
295
|
try:
|
|
@@ -235,6 +400,9 @@ def handle_config_command(args: argparse.Namespace, config: Config) -> int:
|
|
|
235
400
|
f" Clean Extensions: {len(latex_config['clean_extensions'])} extensions"
|
|
236
401
|
)
|
|
237
402
|
print(f" Build Directory: {latex_config['build_dir']}")
|
|
403
|
+
print(f" Engine: {latex_config['engine']}")
|
|
404
|
+
print(f" Shell Escape: {latex_config['shell_escape']}")
|
|
405
|
+
print(f" Timeout: {latex_config['timeout']}s")
|
|
238
406
|
|
|
239
407
|
return 0
|
|
240
408
|
except Exception as e:
|
|
@@ -271,12 +439,18 @@ def main(argv: Optional[list] = None) -> int:
|
|
|
271
439
|
|
|
272
440
|
# Route to appropriate command handler
|
|
273
441
|
try:
|
|
274
|
-
if args.command == "
|
|
442
|
+
if args.command == "init":
|
|
443
|
+
return handle_init_command(args, config)
|
|
444
|
+
|
|
445
|
+
elif args.command == "setup":
|
|
275
446
|
return handle_setup_command(config)
|
|
276
447
|
|
|
277
448
|
elif args.command == "clean":
|
|
278
449
|
return handle_clean_command(config)
|
|
279
450
|
|
|
451
|
+
elif args.command == "compile":
|
|
452
|
+
return handle_compile_command(args, config)
|
|
453
|
+
|
|
280
454
|
elif args.command == "create":
|
|
281
455
|
return handle_create_command(args, config)
|
|
282
456
|
|
|
@@ -169,6 +169,9 @@ class Config:
|
|
|
169
169
|
"latex", "clean_extensions", default_extensions
|
|
170
170
|
),
|
|
171
171
|
"build_dir": self.get("latex", "build_dir", "."),
|
|
172
|
+
"engine": self.get("latex", "engine", "latexmk"),
|
|
173
|
+
"shell_escape": self.get("latex", "shell_escape", False),
|
|
174
|
+
"timeout": self.get("latex", "timeout", 300),
|
|
172
175
|
}
|
|
173
176
|
|
|
174
177
|
def validate_zotero_config(
|
|
@@ -261,6 +264,15 @@ clean_extensions = [
|
|
|
261
264
|
|
|
262
265
|
# Build directory (relative to project root)
|
|
263
266
|
build_dir = "."
|
|
267
|
+
|
|
268
|
+
# Default LaTeX engine
|
|
269
|
+
engine = "latexmk" # Options: "latexmk", "pdflatex"
|
|
270
|
+
|
|
271
|
+
# Enable shell escape by default
|
|
272
|
+
shell_escape = false
|
|
273
|
+
|
|
274
|
+
# Compilation timeout in seconds
|
|
275
|
+
timeout = 300
|
|
264
276
|
"""
|
|
265
277
|
|
|
266
278
|
try:
|