From 0ab515159e9da15e0077d55c761ca0f326361257 Mon Sep 17 00:00:00 2001 From: aidanfnv Date: Tue, 8 Jul 2025 13:41:56 -0700 Subject: Add list and hint on usage in slangc -h (#7638) * Add category list at end of slangc -h output * Use value category for categories * format code (#12) Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com> * Regenerate cmdline reference --------- Co-authored-by: slangbot Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com> --- source/core/slang-command-options-writer.cpp | 7 +++++++ source/slang/slang-options.cpp | 18 ++++++++++++++++++ 2 files changed, 25 insertions(+) (limited to 'source') diff --git a/source/core/slang-command-options-writer.cpp b/source/core/slang-command-options-writer.cpp index 308cc4984..1f1de029d 100644 --- a/source/core/slang-command-options-writer.cpp +++ b/source/core/slang-command-options-writer.cpp @@ -504,6 +504,13 @@ void TextCommandOptionsWriter::appendDescriptionImpl() { _appendDescriptionForCategory(categoryIndex); } + + // Add instructions for getting help for specific categories + m_builder << "Getting Help for Specific Categories\n"; + m_builder << "=====================================\n\n"; + m_builder << "To get help for a specific category of options or values, use: slangc -h " + "\n"; + m_builder << "See the section above for the list of categories.\n\n"; } void TextCommandOptionsWriter::_appendDescriptionForCategory(Index categoryIndex) diff --git a/source/slang/slang-options.cpp b/source/slang/slang-options.cpp index 1b8a45401..af799839c 100644 --- a/source/slang/slang-options.cpp +++ b/source/slang/slang-options.cpp @@ -344,6 +344,24 @@ void initCommandOptions(CommandOptions& options) options.addValues(pairs, SLANG_COUNT_OF(pairs)); } + /* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! help-category !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */ + + { + options.addCategory( + CategoryKind::Value, + "help-category", + "Available help categories for the -h option"); + + // Add all existing categories as valid help category values + const auto& categories = options.getCategories(); + for (Index categoryIndex = 0; categoryIndex < categories.getCount(); ++categoryIndex) + { + const auto& category = categories[categoryIndex]; + options.addValue(category.name, category.description); + } + } + + /* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! General !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */ options.setCategory("General"); -- cgit v1.2.3