Skip to content

Commit 84805d7

Browse files
committed
feat: update version to 1.2.0 and enhance init command functionality
1 parent 0ec71c5 commit 84805d7

File tree

5 files changed

+136
-18
lines changed

5 files changed

+136
-18
lines changed

AGENTS.md

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ flake8 src/
6161
mypy src/
6262

6363
# Local functionality test
64-
pip install -e .
64+
uv pip install -e .
6565
article-cli --version
6666
article-cli --help
6767
article-cli config show
@@ -169,13 +169,12 @@ gh release create v1.0.X --title "v1.0.X - Description" --notes "Release notes"
169169
### Environment Setup:
170170

171171
```bash
172-
# Fresh development environment
172+
# Fresh development environment with uv
173173
cd /Users/prudhomm/Devel/Articles/article.cli
174-
python3 -m venv venv
175-
source venv/bin/activate
176-
pip install --upgrade pip
177-
pip install -e .
178-
pip install black flake8 mypy types-requests pytest
174+
uv venv
175+
source .venv/bin/activate
176+
uv pip install -e .
177+
uv pip install black flake8 mypy types-requests pytest
179178
```
180179

181180
## 📚 Documentation Locations
@@ -231,6 +230,12 @@ gh release create v1.0.X --title "Release v1.0.X" --notes "Release notes"
231230
- `pyproject.toml` - Line with `version = "1.0.X"`
232231
- `src/article_cli/__init__.py` - Line with `__version__ = "1.0.X"`
233232

233+
**Verify locally**:
234+
```bash
235+
uv pip install -e .
236+
article-cli --version
237+
```
238+
234239
---
235240

236241
**Remember**: Always test locally before releasing, and ensure all version-related files are updated consistently!

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
## [1.2.0] - 2025-11-18
11+
12+
### Added
13+
- Init command now creates main.tex file if no .tex file exists in repository
14+
- Support for initializing completely empty repositories
15+
16+
### Changed
17+
- Init command no longer requires pre-existing .tex file
18+
- Init command respects existing files (won't overwrite without --force flag)
19+
- Improved empty repository handling for better user experience
20+
1021
## [1.1.1] - 2025-10-18
1122

1223
### Fixed
@@ -154,6 +165,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
154165
- `article-cli config show` - Show current configuration
155166
- `article-cli config create` - Create sample configuration
156167

168+
[1.2.0]: https://github.com/feelpp/article.cli/releases/tag/v1.2.0
157169
[1.1.1]: https://github.com/feelpp/article.cli/releases/tag/v1.1.1
158170
[1.1.0]: https://github.com/feelpp/article.cli/releases/tag/v1.1.0
159171
[1.0.3]: https://github.com/feelpp/article.cli/releases/tag/v1.0.3

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
44

55
[project]
66
name = "article-cli"
7-
version = "1.1.1"
7+
version = "1.2.0"
88
authors = [
99
{name = "Christophe Prud'homme", email = "[email protected]"},
1010
]

src/article_cli/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
- Git release management with gitinfo2 support
66
- Zotero bibliography synchronization
77
- LaTeX build file cleanup
8-
- Git hooks setup
8+
- Git hooks setup
99
"""
1010

11-
__version__ = "1.1.1"
11+
__version__ = "1.2.0"
1212
__author__ = "Christophe Prud'homme"
1313
__email__ = "[email protected]"
1414

src/article_cli/repository_setup.py

Lines changed: 109 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,23 +45,24 @@ def init_repository(
4545
- .vscode/settings.json with LaTeX Workshop configuration
4646
- LTeX dictionary files for spell checking
4747
- hooks/post-commit for gitinfo2 integration
48+
- main.tex if no .tex file exists
4849
4950
Args:
5051
title: Article title
5152
authors: List of author names
5253
group_id: Zotero group ID
5354
force: Overwrite existing files if True
54-
main_tex_file: Main .tex filename (auto-detected if None)
55+
main_tex_file: Main .tex filename (auto-detected if None, created if missing)
5556
5657
Returns:
5758
True if successful, False otherwise
5859
"""
5960
print_info(f"Initializing repository at: {self.repo_path}")
6061

61-
# Detect or validate main .tex file
62-
tex_file = self._detect_tex_file(main_tex_file)
62+
# Detect or validate main .tex file, create if missing
63+
tex_file = self._detect_or_create_tex_file(main_tex_file, title, authors, force)
6364
if not tex_file:
64-
print_error("No main .tex file found or specified")
65+
print_error("Failed to detect or create main .tex file")
6566
return False
6667

6768
project_name = self.repo_path.name
@@ -111,27 +112,39 @@ def init_repository(
111112
print_error(f"Failed to initialize repository: {e}")
112113
return False
113114

114-
def _detect_tex_file(self, specified: Optional[str]) -> Optional[str]:
115+
def _detect_or_create_tex_file(
116+
self, specified: Optional[str], title: str, authors: List[str], force: bool
117+
) -> Optional[str]:
115118
"""
116-
Detect main .tex file in repository
119+
Detect main .tex file in repository or create one if missing
117120
118121
Args:
119122
specified: User-specified filename (takes priority)
123+
title: Article title (for creating new .tex file)
124+
authors: List of author names (for creating new .tex file)
125+
force: Overwrite existing file if True
120126
121127
Returns:
122-
Main .tex filename or None if not found
128+
Main .tex filename or None on failure
123129
"""
124130
if specified:
125131
tex_path = self.repo_path / specified
126132
if tex_path.exists():
127133
return specified
128-
print_error(f"Specified .tex file not found: {specified}")
134+
# Specified file doesn't exist - create it
135+
if self._create_tex_file(specified, title, authors, force):
136+
return specified
129137
return None
130138

131139
# Auto-detect .tex files
132140
tex_files = list(self.repo_path.glob("*.tex"))
133141

134142
if not tex_files:
143+
# No .tex files found - create main.tex
144+
default_name = "main.tex"
145+
print_info(f"No .tex file found, creating {default_name}")
146+
if self._create_tex_file(default_name, title, authors, force):
147+
return default_name
135148
return None
136149

137150
if len(tex_files) == 1:
@@ -149,6 +162,94 @@ def _detect_tex_file(self, specified: Optional[str]) -> Optional[str]:
149162
)
150163
return tex_files[0].name
151164

165+
def _create_tex_file(
166+
self, filename: str, title: str, authors: List[str], force: bool
167+
) -> bool:
168+
"""
169+
Create a basic LaTeX article file
170+
171+
Args:
172+
filename: Name of the .tex file to create
173+
title: Article title
174+
authors: List of author names
175+
force: Overwrite if exists
176+
177+
Returns:
178+
True if successful
179+
"""
180+
tex_path = self.repo_path / filename
181+
182+
if tex_path.exists() and not force:
183+
print_info(f"{filename} already exists (use --force to overwrite)")
184+
return True
185+
186+
# Format authors for LaTeX
187+
authors_latex = " \\and ".join(authors)
188+
189+
tex_content = f"""\\documentclass[a4paper,11pt]{{article}}
190+
191+
% Essential packages
192+
\\usepackage[utf8]{{inputenc}}
193+
\\usepackage[T1]{{fontenc}}
194+
\\usepackage{{lmodern}}
195+
\\usepackage{{amsmath,amssymb,amsthm}}
196+
\\usepackage{{graphicx}}
197+
\\usepackage{{hyperref}}
198+
\\usepackage[margin=1in]{{geometry}}
199+
200+
% Bibliography
201+
\\usepackage[style=numeric,sorting=none]{{biblatex}}
202+
\\addbibresource{{references.bib}}
203+
204+
% Git version information
205+
\\usepackage{{gitinfo2}}
206+
207+
% Title and authors
208+
\\title{{{title}}}
209+
\\author{{{authors_latex}}}
210+
\\date{{\\today}}
211+
212+
\\begin{{document}}
213+
214+
\\maketitle
215+
216+
\\begin{{abstract}}
217+
Your abstract goes here.
218+
\\end{{abstract}}
219+
220+
\\section{{Introduction}}
221+
222+
Your introduction goes here.
223+
224+
\\section{{Methodology}}
225+
226+
Your methodology goes here.
227+
228+
\\section{{Results}}
229+
230+
Your results go here.
231+
232+
\\section{{Conclusion}}
233+
234+
Your conclusion goes here.
235+
236+
% Print bibliography
237+
\\printbibliography
238+
239+
% Git information (optional - appears in footer)
240+
\\vfill
241+
\\hrule
242+
\\small
243+
\\noindent Git version: \\gitAbbrevHash{{}} (\\gitAuthorIsoDate) \\\\
244+
Branch: \\gitBranch
245+
246+
\\end{{document}}
247+
"""
248+
249+
tex_path.write_text(tex_content)
250+
print_success(f"Created: {tex_path.relative_to(self.repo_path)}")
251+
return True
252+
152253
def _create_directories(self) -> None:
153254
"""Create necessary directory structure"""
154255
directories = [

0 commit comments

Comments
 (0)