MCPcopy Create free account
hub / github.com/RightNow-AI/rightnow-cli / _select_file

Method _select_file

rightnow_cli/interactive.py:167–199  ·  view source on GitHub ↗

Select file with arrow keys.

(self, files: List[Path])

Source from the content-addressed store, hash-verified

165 return sorted(cu_files + cuh_files, key=lambda x: x.stat().st_mtime, reverse=True)
166
167 def _select_file(self, files: List[Path]) -> Optional[Path]:
168 """Select file with arrow keys."""
169
170 if len(files) == 1:
171 console.print(f"[green]Using {files[0].name}[/green]")
172 return files[0]
173
174 import datetime
175 choices = []
176 for f in files[:20]:
177 kernels = self._parse_kernels(f)
178 size = f.stat().st_size / 1024
179 size_str = f"{size:.1f}KB" if size < 1024 else f"{size/1024:.1f}MB"
180 date = datetime.datetime.fromtimestamp(f.stat().st_mtime).strftime("%Y-%m-%d")
181
182 label = f"{f.name:30s} {size_str:8s} {len(kernels):2d} kernels {date}"
183 choices.append((label, f))
184
185 questions = [
186 inquirer.List('file',
187 message="Select file to optimize",
188 choices=choices,
189 carousel=True)
190 ]
191
192 try:
193 answers = inquirer.prompt(questions, theme=GreenPassion())
194 if answers:
195 return answers.get('file')
196 return None
197 except Exception as e:
198 console.print(f"[red]Error: {e}[/red]")
199 return None
200
201 def _parse_kernels(self, file: Path) -> List[Dict[str, Any]]:
202 """Parse kernels from file."""

Callers 1

_optimize_workflowMethod · 0.95

Calls 2

_parse_kernelsMethod · 0.95
getMethod · 0.45

Tested by

no test coverage detected