Framework updates

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
root
2025-12-18 18:18:05 +00:00
parent 14dd2fd223
commit 1a5d93140c
6 changed files with 789 additions and 33 deletions

View File

@@ -30,14 +30,19 @@ class Man_Command extends Command
/**
* Create a new command instance.
*
* Directories are listed in priority order - first match wins for same-named files.
* Project-specific docs in rsx/resource/man override framework docs in app/RSpade/man.
*
* @return void
*/
public function __construct()
{
parent::__construct();
// Priority order: project-specific > user docs > framework docs
$this->docs_dirs = [
base_path('docs/man'),
base_path('app/RSpade/man'),
base_path('../rsx/resource/man'), // Project-specific (highest priority)
base_path('docs/man'), // User docs
base_path('app/RSpade/man'), // Framework docs (lowest priority)
];
}
@@ -100,15 +105,7 @@ class Man_Command extends Command
*/
protected function list_all_documentation()
{
$files = [];
foreach ($this->docs_dirs as $dir) {
if (is_dir($dir)) {
$dir_files = glob($dir . '/*.txt');
if ($dir_files) {
$files = array_merge($files, $dir_files);
}
}
}
$files = $this->get_all_files_deduplicated();
if (empty($files)) {
$this->warn('No documentation files found in:');
@@ -175,6 +172,32 @@ class Man_Command extends Command
return 0;
}
/**
* Get all documentation files, deduplicated by filename.
* Files from earlier directories in docs_dirs take precedence.
*
* @return array
*/
protected function get_all_files_deduplicated(): array
{
$files_by_name = [];
foreach ($this->docs_dirs as $dir) {
if (is_dir($dir)) {
$dir_files = glob($dir . '/*.txt');
if ($dir_files) {
foreach ($dir_files as $file) {
$name = basename($file, '.txt');
// First occurrence wins (higher priority directory)
if (!isset($files_by_name[$name])) {
$files_by_name[$name] = $file;
}
}
}
}
}
return array_values($files_by_name);
}
/**
* Find documentation files matching the given term.
*
@@ -183,15 +206,7 @@ class Man_Command extends Command
*/
protected function find_matching_files(string $term): array
{
$files = [];
foreach ($this->docs_dirs as $dir) {
if (is_dir($dir)) {
$dir_files = glob($dir . '/*.txt');
if ($dir_files) {
$files = array_merge($files, $dir_files);
}
}
}
$files = $this->get_all_files_deduplicated();
$term_lower = strtolower($term);
$matches = [];
@@ -373,25 +388,14 @@ class Man_Command extends Command
*/
protected function get_all_topic_names(): array
{
$files = [];
foreach ($this->docs_dirs as $dir) {
if (is_dir($dir)) {
$dir_files = glob($dir . '/*.txt');
if ($dir_files) {
$files = array_merge($files, $dir_files);
}
}
}
$files = $this->get_all_files_deduplicated();
$topics = [];
foreach ($files as $file) {
$topics[] = basename($file, '.txt');
}
// Remove duplicates and sort
$topics = array_unique($topics);
sort($topics);
return $topics;
}