article-cli 1.0.3__tar.gz → 1.1.0__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: article-cli
3
- Version: 1.0.3
3
+ Version: 1.1.0
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
- - **Local Configuration**: Support for project-specific configuration files
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** (one-time setup):
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
- - **Local Configuration**: Support for project-specific configuration files
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** (one-time setup):
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
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "article-cli"
7
- version = "1.0.3"
7
+ version = "1.1.0"
8
8
  authors = [
9
9
  {name = "Christophe Prud'homme", email = "prudhomm@cemosis.fr"},
10
10
  ]
@@ -8,7 +8,7 @@ This package provides tools for:
8
8
  - Git hooks setup
9
9
  """
10
10
 
11
- __version__ = "1.0.3"
11
+ __version__ = "1.1.0"
12
12
  __author__ = "Christophe Prud'homme"
13
13
  __email__ = "prudhomm@cemosis.fr"
14
14
 
@@ -16,5 +16,7 @@ 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__ = ["main", "Config", "ZoteroBibTexUpdater", "GitManager"]
22
+ __all__ = ["main", "Config", "ZoteroBibTexUpdater", "GitManager", "RepositorySetup", "LaTeXCompiler"]
@@ -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,77 @@ 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(
60
+ "--title", required=True, help="Article title"
61
+ )
62
+ init_parser.add_argument(
63
+ "--authors",
64
+ required=True,
65
+ help='Comma-separated list of authors (e.g., "John Doe,Jane Smith")',
66
+ )
67
+ init_parser.add_argument(
68
+ "--group-id",
69
+ default="4678293",
70
+ help="Zotero group ID (default: 4678293 for article.template)",
71
+ )
72
+ init_parser.add_argument(
73
+ "--tex-file",
74
+ help="Main .tex file (auto-detected if not specified)",
75
+ )
76
+ init_parser.add_argument(
77
+ "--force",
78
+ action="store_true",
79
+ help="Overwrite existing files",
80
+ )
81
+
49
82
  # Setup command
50
83
  subparsers.add_parser("setup", help="Setup git hooks for gitinfo2")
51
84
 
52
85
  # Clean command
53
86
  subparsers.add_parser("clean", help="Clean LaTeX build files")
54
87
 
88
+ # Compile command
89
+ compile_parser = subparsers.add_parser("compile", help="Compile LaTeX document using latexmk")
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",
113
+ action="store_true",
114
+ help="Clean build files after compilation"
115
+ )
116
+ compile_parser.add_argument(
117
+ "--watch",
118
+ action="store_true",
119
+ help="Watch for changes and recompile automatically"
120
+ )
121
+ compile_parser.add_argument(
122
+ "--output-dir",
123
+ help="Output directory for compiled files"
124
+ )
125
+
55
126
  # Create command
56
127
  create_parser = subparsers.add_parser("create", help="Create a new release")
57
128
  create_parser.add_argument("version", help="Version tag (e.g., v1.0.0)")
@@ -102,6 +173,29 @@ Environment variables:
102
173
  return parser
103
174
 
104
175
 
176
+ def handle_init_command(args: argparse.Namespace, config: Config) -> int:
177
+ """Handle the init command"""
178
+ try:
179
+ # Parse comma-separated authors
180
+ authors = [a.strip() for a in args.authors.split(",")]
181
+
182
+ repo_setup = RepositorySetup()
183
+ return (
184
+ 0
185
+ if repo_setup.init_repository(
186
+ title=args.title,
187
+ authors=authors,
188
+ group_id=args.group_id,
189
+ force=args.force,
190
+ main_tex_file=args.tex_file,
191
+ )
192
+ else 1
193
+ )
194
+ except Exception as e:
195
+ print_error(f"Failed to initialize repository: {e}")
196
+ return 1
197
+
198
+
105
199
  def handle_setup_command(config: Config) -> int:
106
200
  """Handle the setup command"""
107
201
  try:
@@ -125,6 +219,78 @@ def handle_clean_command(config: Config) -> int:
125
219
  return 1
126
220
 
127
221
 
222
+ def handle_compile_command(args: argparse.Namespace, config: Config) -> int:
223
+ """Handle the compile command"""
224
+ try:
225
+ from .latex_compiler import LaTeXCompiler
226
+
227
+ # Auto-detect tex file if not provided
228
+ tex_file = args.tex_file
229
+ if not tex_file:
230
+ tex_file = _auto_detect_tex_file()
231
+ if not tex_file:
232
+ print_error("No .tex file specified and none found in current directory")
233
+ return 1
234
+
235
+ # Validate tex file exists
236
+ tex_path = Path(tex_file)
237
+ if not tex_path.exists():
238
+ print_error(f"LaTeX file not found: {tex_file}")
239
+ return 1
240
+
241
+ compiler = LaTeXCompiler(config)
242
+
243
+ # Clean before compilation if requested
244
+ if args.clean_first:
245
+ print_info("Cleaning build files before compilation...")
246
+ git_manager = GitManager()
247
+ latex_config = config.get_latex_config()
248
+ git_manager.clean_latex_files(latex_config["clean_extensions"])
249
+
250
+ # Compile the document
251
+ success = compiler.compile(
252
+ tex_file=tex_file,
253
+ engine=args.engine,
254
+ shell_escape=args.shell_escape,
255
+ output_dir=args.output_dir,
256
+ watch=args.watch
257
+ )
258
+
259
+ # Clean after compilation if requested
260
+ if args.clean_after and success:
261
+ print_info("Cleaning build files after compilation...")
262
+ git_manager = GitManager()
263
+ latex_config = config.get_latex_config()
264
+ git_manager.clean_latex_files(latex_config["clean_extensions"])
265
+
266
+ return 0 if success else 1
267
+
268
+ except Exception as e:
269
+ print_error(f"Compilation failed: {e}")
270
+ return 1
271
+
272
+
273
+ def _auto_detect_tex_file() -> Optional[str]:
274
+ """Auto-detect main .tex file in current directory"""
275
+ current_dir = Path.cwd()
276
+ tex_files = list(current_dir.glob("*.tex"))
277
+
278
+ if not tex_files:
279
+ return None
280
+
281
+ if len(tex_files) == 1:
282
+ return tex_files[0].name
283
+
284
+ # Multiple .tex files - prefer common patterns
285
+ for pattern in ["main.tex", "article.tex", f"{current_dir.name}.tex"]:
286
+ if (current_dir / pattern).exists():
287
+ return pattern
288
+
289
+ # Return first .tex file found
290
+ print_info(f"Multiple .tex files found, using: {tex_files[0].name}")
291
+ return tex_files[0].name
292
+
293
+
128
294
  def handle_create_command(args: argparse.Namespace, config: Config) -> int:
129
295
  """Handle the create command"""
130
296
  try:
@@ -235,6 +401,9 @@ def handle_config_command(args: argparse.Namespace, config: Config) -> int:
235
401
  f" Clean Extensions: {len(latex_config['clean_extensions'])} extensions"
236
402
  )
237
403
  print(f" Build Directory: {latex_config['build_dir']}")
404
+ print(f" Engine: {latex_config['engine']}")
405
+ print(f" Shell Escape: {latex_config['shell_escape']}")
406
+ print(f" Timeout: {latex_config['timeout']}s")
238
407
 
239
408
  return 0
240
409
  except Exception as e:
@@ -271,12 +440,18 @@ def main(argv: Optional[list] = None) -> int:
271
440
 
272
441
  # Route to appropriate command handler
273
442
  try:
274
- if args.command == "setup":
443
+ if args.command == "init":
444
+ return handle_init_command(args, config)
445
+
446
+ elif args.command == "setup":
275
447
  return handle_setup_command(config)
276
448
 
277
449
  elif args.command == "clean":
278
450
  return handle_clean_command(config)
279
451
 
452
+ elif args.command == "compile":
453
+ return handle_compile_command(args, config)
454
+
280
455
  elif args.command == "create":
281
456
  return handle_create_command(args, config)
282
457
 
@@ -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: