article-cli 1.1.1__tar.gz → 1.2.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.1.1
3
+ Version: 1.2.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
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "article-cli"
7
- version = "1.1.1"
7
+ version = "1.2.0"
8
8
  authors = [
9
9
  {name = "Christophe Prud'homme", email = "prudhomm@cemosis.fr"},
10
10
  ]
@@ -5,10 +5,10 @@ This package provides tools for:
5
5
  - Git release management with gitinfo2 support
6
6
  - Zotero bibliography synchronization
7
7
  - LaTeX build file cleanup
8
- - Git hooks setup
8
+ - Git hooks setup
9
9
  """
10
10
 
11
- __version__ = "1.1.1"
11
+ __version__ = "1.2.0"
12
12
  __author__ = "Christophe Prud'homme"
13
13
  __email__ = "prudhomm@cemosis.fr"
14
14
 
@@ -45,23 +45,24 @@ class RepositorySetup:
45
45
  - .vscode/settings.json with LaTeX Workshop configuration
46
46
  - LTeX dictionary files for spell checking
47
47
  - hooks/post-commit for gitinfo2 integration
48
+ - main.tex if no .tex file exists
48
49
 
49
50
  Args:
50
51
  title: Article title
51
52
  authors: List of author names
52
53
  group_id: Zotero group ID
53
54
  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)
55
56
 
56
57
  Returns:
57
58
  True if successful, False otherwise
58
59
  """
59
60
  print_info(f"Initializing repository at: {self.repo_path}")
60
61
 
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)
63
64
  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")
65
66
  return False
66
67
 
67
68
  project_name = self.repo_path.name
@@ -111,27 +112,39 @@ class RepositorySetup:
111
112
  print_error(f"Failed to initialize repository: {e}")
112
113
  return False
113
114
 
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]:
115
118
  """
116
- Detect main .tex file in repository
119
+ Detect main .tex file in repository or create one if missing
117
120
 
118
121
  Args:
119
122
  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
120
126
 
121
127
  Returns:
122
- Main .tex filename or None if not found
128
+ Main .tex filename or None on failure
123
129
  """
124
130
  if specified:
125
131
  tex_path = self.repo_path / specified
126
132
  if tex_path.exists():
127
133
  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
129
137
  return None
130
138
 
131
139
  # Auto-detect .tex files
132
140
  tex_files = list(self.repo_path.glob("*.tex"))
133
141
 
134
142
  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
135
148
  return None
136
149
 
137
150
  if len(tex_files) == 1:
@@ -149,6 +162,94 @@ class RepositorySetup:
149
162
  )
150
163
  return tex_files[0].name
151
164
 
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
+
152
253
  def _create_directories(self) -> None:
153
254
  """Create necessary directory structure"""
154
255
  directories = [
File without changes
File without changes
File without changes