Skip to content

Update tl flag#6536

Merged
Mzack9999 merged 4 commits intoprojectdiscovery:devfrom
matejsmycka:update-tl-flag
Oct 23, 2025
Merged

Update tl flag#6536
Mzack9999 merged 4 commits intoprojectdiscovery:devfrom
matejsmycka:update-tl-flag

Conversation

@matejsmycka
Copy link
Contributor

@matejsmycka matejsmycka commented Oct 15, 2025

Proposed changes

In this MR, I have added two things:

  • Changed description of tl flag because it's not evident that "ALL templates" means "ALL selected templates". This would save me some time
  • Also implemented ordering alphabetically, so it is visually easier to navigate.

Checklist

  • Pull request is created against the dev branch
  • All checks passed (lint, unit/integration/regression tests etc.) with my changes
  • [] I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)

Summary by CodeRabbit

  • Documentation
    • Updated CLI help and README for the -tl flag to clarify it lists templates matching current filters, improving accuracy of usage guidance.
  • Style
    • Template listings are now presented in alphabetical order, making results easier to scan and compare across outputs (including verbose and flag-driven listings).

@auto-assign auto-assign bot requested a review from dogancanbakir October 15, 2025 07:44
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 15, 2025

Walkthrough

Updated CLI/help text for the -tl flag to state it lists templates matching current filters; internal template listing now sorts templates alphabetically by Path before applying filters and rendering. No public API signatures changed.

Changes

Cohort / File(s) Summary of changes
Documentation update
README.md
Changed -tl flag description to “list all templates matching current filters.”
CLI help text
cmd/nuclei/main.go
Adjusted TemplateList (-tl) help text to reflect filtered listing behavior.
Template listing order
internal/runner/templates.go
Collects store templates into a slice and sorts them by Path (alphabetical) before iterating and applying filters; iteration order changed only.

Sequence Diagram(s)

sequenceDiagram
    autonumber
    participant U as User
    participant C as CLI (main)
    participant R as Runner
    participant S as Store

    U->>C: nuclei -tl [filters]
    Note right of C: Help text updated to indicate filtered listing
    C->>R: parse flags & request template list
    R->>S: Templates()
    S-->>R: []Template
    Note over R: NEW: collect into slice and sort by Path (A→Z)
    R->>R: apply current filters to sorted list
    R-->>C: filtered, sorted template list
    C-->>U: display templates
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

I hop through paths in tidy rows,
Sorting names where spring wind blows.
Flags whisper filters, crisp and clear,
The list aligns — all held dear.
A rabbit cheers: the CLI shows. 🐰✨

Pre-merge checks and finishing touches

❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Title Check ❓ Inconclusive The title is related to the flag being updated but is overly generic and does not convey the specific changes made to its description or the addition of alphabetical sorting, making it hard to understand the primary intent at a glance. Consider revising the title to briefly summarize the key updates, for example “Clarify tl flag help text and sort templates alphabetically.”
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
internal/runner/templates.go (1)

47-51: Capture store.Templates() once and reuse
Assign the result of store.Templates() to a local variable, then sort and range over that to avoid repeated calls:

-	// order templates alphabetically by path
-	sort.Slice(store.Templates(), func(i, j int) bool {
-		return store.Templates()[i].Path < store.Templates()[j].Path
-	})
-
-	for _, tpl := range store.Templates() {
+	// order templates alphabetically by path
+	templates := store.Templates()
+	sort.Slice(templates, func(i, j int) bool {
+		return templates[i].Path < templates[j].Path
+	})
+
+	for _, tpl := range templates {

This reduces function-call overhead in the comparator and loop.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 19554a7 and cd41cb9.

📒 Files selected for processing (3)
  • README.md (1 hunks)
  • cmd/nuclei/main.go (1 hunks)
  • internal/runner/templates.go (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.go

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.go: Format Go code using go fmt
Run static analysis with go vet

Files:

  • cmd/nuclei/main.go
  • internal/runner/templates.go
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Lint
🔇 Additional comments (2)
README.md (1)

166-166: LGTM! Clear documentation update.

The updated description accurately reflects that the -tl flag lists filtered templates rather than all available templates, improving user understanding of the flag's behavior.

cmd/nuclei/main.go (1)

283-283: LGTM! Consistent help text update.

The CLI help text now accurately describes that the -tl flag lists templates matching current filters, consistent with the README documentation and the sorting behavior implemented in internal/runner/templates.go.

@matejsmycka
Copy link
Contributor Author

will fix

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between cd41cb9 and 427007c.

📒 Files selected for processing (1)
  • internal/runner/templates.go (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.go

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.go: Format Go code using go fmt
Run static analysis with go vet

Files:

  • internal/runner/templates.go
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Tests (windows-latest)
  • GitHub Check: Tests (macOS-latest)
  • GitHub Check: Tests (ubuntu-latest)

@matejsmycka
Copy link
Contributor Author

idk why the integration tests are failing. Would you be so kind, @dogancanbakir, and look at it, please?

@Mzack9999
Copy link
Member

@coderabbitai create an issue for this PR

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 23, 2025

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Get PR details and check status
gh pr view 6536 --repo projectdiscovery/nuclei --json title,body,url,checks,statusCheckRollup

# Get the specific comment URL context
gh pr view 6536 --repo projectdiscovery/nuclei --comments --json comments | jq '.comments[] | select(.author.login == "matejsmycka") | {body: .body, url: .url, createdAt: .createdAt}'

Length of output: 1070


🏁 Script executed:

#!/bin/bash
# Get PR details with correct fields
gh pr view 6536 --repo projectdiscovery/nuclei --json title,body,url,state,statusCheckRollup,mergeStateStatus

# Get the URL of the current comment thread (the one where Mzack9999 asked to create issue)
gh pr view 6536 --repo projectdiscovery/nuclei --comments --json comments | jq '.comments[] | select(.author.login == "Mzack9999" and (.body | contains("create an issue"))) | {body: .body, url: .url}'

Length of output: 7395


@Mzack9999, I can help create an issue for this PR. However, I need clarification on what the issue should track:

Looking at the current status:

  • All tests (including integration tests) are now passing as of October 23
  • The PR updates the -tl flag description and adds alphabetical sorting of templates
  • The checklist item for adding tests is unchecked

What would you like the issue to address?

  1. Missing tests for the new alphabetical sorting functionality?
  2. A follow-up task related to this PR?
  3. Something else specific you'd like tracked?

Please let me know the focus and I'll create an appropriately titled and detailed issue assigned to you.

@Mzack9999
Copy link
Member

@coderabbitai create an issue for this PR. The issue is about better flag description and templates sorting

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 23, 2025

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Create a GitHub issue for PR #6536

gh issue create \
  --repo projectdiscovery/nuclei \
  --title "Improve -tl flag description and add alphabetical template sorting" \
  --body "This issue tracks improvements to the template listing functionality:

1. **Better flag description**: Updated the \`-tl\` flag description to clarify that it lists templates matching current filters rather than all available templates.

2. **Templates sorting**: Added alphabetical sorting of templates by path to improve visual navigation when listing templates.

**Related PR**: https://github.com/projectdiscovery/nuclei/pull/6536
**Requested by**: @Mzack9999" \
  --assignee Mzack9999

Length of output: 54


@Mzack9999, I've created issue #6546 for this PR: #6546

The issue tracks both improvements:

  • Better -tl flag description (clarifying it lists templates matching current filters)
  • Alphabetical template sorting by path

The issue has been assigned to you as requested.

@Mzack9999 Mzack9999 linked an issue Oct 23, 2025 that may be closed by this pull request
@Mzack9999 Mzack9999 merged commit 71293f2 into projectdiscovery:dev Oct 23, 2025
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve -tl flag description and add alphabetical template sorting

3 participants