# cstats PowerShell Hook
# Generated automatically - do not edit manually
# Shell: {{shell_type}}
# Default source: {{default_source}}
# Environment variables
{{env_vars}}
# Core cstats wrapper function
function Invoke-CStatsWrap {
param(
[Parameter(Mandatory=$true, ValueFromRemainingArguments=$true)]
[string[]]$Command
)
$cmdString = $Command -join ' '
& {{cstats_path}} collect --source "{{default_source}}" --command $cmdString
}
# Convenient alias for manual usage
Set-Alias -Name cs -Value Invoke-CStatsWrap
# Auto-wrapped commands
{{auto_commands}}
# Utility functions
function Show-CStatsRecent {
param([int]$Hours = 1)
$startTime = (Get-Date).AddHours(-$Hours).ToString("yyyy-MM-ddTHH:mm:ssZ")
& {{cstats_path}} analyze --source "{{default_source}}" --start-time $startTime
}
function Show-CStatsToday {
$startTime = (Get-Date -Hour 0 -Minute 0 -Second 0).ToString("yyyy-MM-ddTHH:mm:ssZ")
& {{cstats_path}} analyze --source "{{default_source}}" --start-time $startTime
}
function Clear-CStatsCache {
& {{cstats_path}} cache clear
}
function Show-CStatsStatus {
& {{cstats_path}} cache stats
}
# PowerShell-specific: command history tracking
{{#if auto_collect_all}}
# CAUTION: This will collect statistics for ALL commands
# Uncomment the following to enable:
# $ExecutionContext.InvokeCommand.CommandNotFoundAction = {
# param($CommandName, $CommandLookupEventArgs)
# Start-Job -ScriptBlock {
# & {{cstats_path}} collect --source "{{default_source}}" --command $using:CommandName
# } | Out-Null
# }
{{/if}}
Write-Host "✓ cstats {{shell_type}} hook loaded. Use 'cs <command>' to collect statistics." -ForegroundColor Green