Skip to content

Commit 4cb9bbc

Browse files
authored
Merge pull request #37 from jdarcyryan/jdr/enums-and-arg-completion
jdr/enums-and-arg-completion
2 parents 07a1cc5 + 68a4bf0 commit 4cb9bbc

22 files changed

Lines changed: 875 additions & 34 deletions

.build/template/Template.psm1

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,18 @@ if (Test-Path -Path $classesDataFilePath) {
5858

5959
#endregion Classes
6060

61+
#region Enums
62+
63+
$enumsPath = "$PSScriptRoot\enums"
64+
65+
if (Test-Path -Path $enumsPath) {
66+
Get-ChildItem -Path $enumsPath -Filter '*.ps1' | where PSIsContainer -eq $false | foreach {
67+
. $_.FullName
68+
}
69+
}
70+
71+
#endregion Enums
72+
6173
#region Private
6274

6375
$privatePath = "$PSScriptRoot\private"
@@ -81,3 +93,15 @@ if (Test-Path -Path $publicPath) {
8193
}
8294

8395
#endregion Public
96+
97+
#region Completers
98+
99+
$completersPath = "$PSScriptRoot\completers"
100+
101+
if (Test-Path -Path $completersPath) {
102+
Get-ChildItem -Path $completersPath -Filter '*.ps1' | where PSIsContainer -eq $false | foreach {
103+
. $_.FullName
104+
}
105+
}
106+
107+
#region Completers

.build/template/enums/.gitkeep

Whitespace-only changes.

.github/workflows/pages.yml

Lines changed: 14 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ name: Deploy to GitHub Pages
33
on:
44
push:
55
branches: ["main"]
6+
workflow_dispatch:
67

78
permissions:
89
contents: read
@@ -117,20 +118,11 @@ jobs:
117118
<link href="https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;500&family=IBM+Plex+Mono:wght@400;500&display=swap" rel="stylesheet">
118119
<style>
119120
:root{
120-
--bg-page:#f6f8fa;--bg-content:#fff;--bg-header:#fff;--bg-code:#f6f8fa;
121-
--text-primary:#24292f;--text-secondary:#57606a;--text-muted:#8b949e;
122-
--border:#d0d7de;--link:#0969da;--accent:#fd8c73;
123-
--badge-bg:#dafbe1;--badge-text:#1a7f37;
124-
--inline-code-bg:#eff1f3;--inline-code-text:#24292f;
125-
}
126-
@media(prefers-color-scheme:dark){
127-
:root{
128-
--bg-page:#0d1117;--bg-content:#161b22;--bg-header:#161b22;--bg-code:#1c2129;
129-
--text-primary:#e6edf3;--text-secondary:#8b949e;--text-muted:#6e7681;
130-
--border:#30363d;--link:#58a6ff;--accent:#f78166;
131-
--badge-bg:#1b3826;--badge-text:#3fb950;
132-
--inline-code-bg:#343942;--inline-code-text:#e6edf3;
133-
}
121+
--bg-page:#0d1117;--bg-content:#161b22;--bg-header:#161b22;--bg-code:#1c2129;
122+
--text-primary:#e6edf3;--text-secondary:#8b949e;--text-muted:#6e7681;
123+
--border:#30363d;--link:#58a6ff;--accent:#f78166;
124+
--badge-bg:#1b3826;--badge-text:#3fb950;
125+
--inline-code-bg:#343942;--inline-code-text:#e6edf3;
134126
}
135127
*{margin:0;padding:0;box-sizing:border-box}
136128
body{font-family:'IBM Plex Sans',-apple-system,sans-serif;color:var(--text-primary);background:var(--bg-page);line-height:1.7}
@@ -163,24 +155,14 @@ jobs:
163155
pre[class*="language-"]{background:var(--bg-code) !important;padding:12px 16px;margin:8px 0 16px;color:var(--text-primary)}
164156
pre[class*="language-"] code,code[class*="language-"]{background:transparent !important;color:inherit !important}
165157
.token{background:none !important;text-shadow:none !important}
166-
.token.comment,.token.prolog,.token.doctype,.token.cdata{color:#6a737d !important;font-style:italic}
167-
.token.punctuation{color:#24292f !important}
168-
.token.property,.token.tag,.token.boolean,.token.number,.token.constant,.token.symbol,.token.deleted{color:#005cc5 !important}
169-
.token.selector,.token.attr-name,.token.string,.token.char,.token.builtin,.token.inserted{color:#032f62 !important}
170-
.token.operator,.token.entity,.token.url{color:#d73a49 !important}
171-
.token.atrule,.token.attr-value,.token.keyword{color:#d73a49 !important}
172-
.token.function,.token.class-name{color:#6f42c1 !important}
173-
.token.regex,.token.important,.token.variable{color:#e36209 !important}
174-
@media(prefers-color-scheme:dark){
175-
.token.comment,.token.prolog,.token.doctype,.token.cdata{color:#8b949e !important}
176-
.token.punctuation{color:#c9d1d9 !important}
177-
.token.property,.token.tag,.token.boolean,.token.number,.token.constant,.token.symbol,.token.deleted{color:#ff7b72 !important}
178-
.token.selector,.token.attr-name,.token.string,.token.char,.token.builtin,.token.inserted{color:#a5d6ff !important}
179-
.token.operator,.token.entity,.token.url{color:#79c0ff !important}
180-
.token.atrule,.token.attr-value,.token.keyword{color:#d2a8ff !important}
181-
.token.function,.token.class-name{color:#d2a8ff !important}
182-
.token.regex,.token.important,.token.variable{color:#ffa657 !important}
183-
}
158+
.token.comment,.token.prolog,.token.doctype,.token.cdata{color:#8b949e !important;font-style:italic}
159+
.token.punctuation{color:#c9d1d9 !important}
160+
.token.property,.token.tag,.token.boolean,.token.number,.token.constant,.token.symbol,.token.deleted{color:#ff7b72 !important}
161+
.token.selector,.token.attr-name,.token.string,.token.char,.token.builtin,.token.inserted{color:#a5d6ff !important}
162+
.token.operator,.token.entity,.token.url{color:#79c0ff !important}
163+
.token.atrule,.token.attr-value,.token.keyword{color:#d2a8ff !important}
164+
.token.function,.token.class-name{color:#d2a8ff !important}
165+
.token.regex,.token.important,.token.variable{color:#ffa657 !important}
184166
details>summary{list-style:none}
185167
details>summary::-webkit-details-marker{display:none}
186168
.collapsible{border:1px solid var(--border);border-radius:6px;margin-bottom:8px}
Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
#
2+
# Module manifest for module 'PSModuleTemplate'
3+
#
4+
# Generated by: jdarcyryan
5+
#
6+
# Generated on: 22/02/2026
7+
#
8+
9+
@{
10+
11+
# Script module or binary module file associated with this manifest.
12+
RootModule = 'PSModuleTemplate.psm1'
13+
14+
# Version number of this module.
15+
ModuleVersion = '0.3.0'
16+
17+
# Supported PSEditions
18+
# CompatiblePSEditions = @()
19+
20+
# ID used to uniquely identify this module
21+
GUID = '3101ef4b-0651-47b8-ac62-adbe531f52fe'
22+
23+
# Author of this module
24+
Author = 'jdarcyryan'
25+
26+
# Company or vendor of this module
27+
CompanyName = 'jdarcyryan'
28+
29+
# Copyright statement for this module
30+
Copyright = 'Apache 2.0 License'
31+
32+
# Description of the functionality provided by this module
33+
Description = 'PSModuleTemplate'
34+
35+
# Minimum version of the PowerShell engine required by this module
36+
# PowerShellVersion = ''
37+
38+
# Name of the PowerShell host required by this module
39+
# PowerShellHostName = ''
40+
41+
# Minimum version of the PowerShell host required by this module
42+
# PowerShellHostVersion = ''
43+
44+
# Minimum version of Microsoft .NET Framework required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
45+
# DotNetFrameworkVersion = ''
46+
47+
# Minimum version of the common language runtime (CLR) required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
48+
# ClrVersion = ''
49+
50+
# Processor architecture (None, X86, Amd64) required by this module
51+
# ProcessorArchitecture = ''
52+
53+
# Modules that must be imported into the global environment prior to importing this module
54+
# RequiredModules = @()
55+
56+
# Assemblies that must be loaded prior to importing this module
57+
# RequiredAssemblies = @()
58+
59+
# Script files (.ps1) that are run in the caller's environment prior to importing this module.
60+
# ScriptsToProcess = @()
61+
62+
# Type files (.ps1xml) to be loaded when importing this module
63+
# TypesToProcess = @()
64+
65+
# Format files (.ps1xml) to be loaded when importing this module
66+
# FormatsToProcess = @()
67+
68+
# Modules to import as nested modules of the module specified in RootModule/ModuleToProcess
69+
# NestedModules = @()
70+
71+
# Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export.
72+
FunctionsToExport = @('Get-Greeting', 'Set-SimpleMessage', 'Invoke-ClassDemo')
73+
74+
# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
75+
CmdletsToExport = @()
76+
77+
# Variables to export from this module
78+
VariablesToExport = @()
79+
80+
# Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export.
81+
AliasesToExport = @()
82+
83+
# DSC resources to export from this module
84+
# DscResourcesToExport = @()
85+
86+
# List of all modules packaged with this module
87+
# ModuleList = @()
88+
89+
# List of all files packaged with this module
90+
# FileList = @()
91+
92+
# Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell.
93+
PrivateData = @{
94+
95+
PSData = @{
96+
97+
# Tags applied to this module. These help with module discovery in online galleries.
98+
# Tags = @()
99+
100+
# A URL to the license for this module.
101+
# LicenseUri = ''
102+
103+
# A URL to the main website for this project.
104+
# ProjectUri = ''
105+
106+
# A URL to an icon representing this module.
107+
# IconUri = ''
108+
109+
# ReleaseNotes of this module
110+
# ReleaseNotes = ''
111+
112+
# Prerelease string of this module
113+
# Prerelease = ''
114+
115+
# Flag to indicate whether the module requires explicit user acceptance for install/update/save
116+
# RequireLicenseAcceptance = $false
117+
118+
# External dependent modules of this module
119+
# ExternalModuleDependencies = @()
120+
121+
} # End of PSData hashtable
122+
123+
} # End of PrivateData hashtable
124+
125+
# HelpInfo URI of this module
126+
# HelpInfoURI = ''
127+
128+
# Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix.
129+
# DefaultCommandPrefix = ''
130+
131+
}
132+
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
#region Authoring
2+
3+
###########################################################################
4+
# PSModuleTemplate
5+
# Author: James D'Arcy Ryan
6+
# GitHub: https://github.com/jdarcyryan/PSModuleTemplate
7+
# License: https://github.com/jdarcyryan/PSModuleTemplate/blob/main/LICENSE
8+
#
9+
# A standardized template for creating PowerShell modules with support for
10+
# classes (PowerShell and C#), private functions, and public functions with
11+
# automatic discovery and export of commands and aliases.
12+
#
13+
# LEGAL NOTICE:
14+
# The license referenced above applies to the PSModuleTemplate repository
15+
# and template structure only. Any module created using this template is
16+
# subject to its own license as specified in the module's LICENSE file,
17+
# which supersedes the template license for that specific module.
18+
###########################################################################
19+
20+
#region Authoring
21+
22+
#region Classes
23+
24+
$classesPath = "$PSScriptRoot\classes"
25+
$classesDataFilePath = "$classesPath\classes.psd1"
26+
27+
if (Test-Path -Path $classesDataFilePath) {
28+
$classes = (Import-PowerShellDataFile -Path $classesDataFilePath).classes
29+
30+
$classes | foreach {
31+
$currentClassPath = "$classesPath\$_"
32+
33+
if (!(Test-Path -Path $currentClassPath)) {
34+
throw "Class '$_' does not exist."
35+
}
36+
37+
$extension = (Get-Item -Path $currentClassPath).Extension
38+
39+
switch ($extension) {
40+
'.ps1' {
41+
# Process standard classes
42+
. $currentClassPath
43+
}
44+
'.cs' {
45+
# Process CSharp classes
46+
Add-Type -Path $currentClassPath
47+
}
48+
'.dll' {
49+
# Process DLLs
50+
Add-Type -Path $currentClassPath
51+
}
52+
default {
53+
throw "Unable to process class '$_', $extension is an unsupported file type."
54+
}
55+
}
56+
}
57+
}
58+
59+
#endregion Classes
60+
61+
#region Enums
62+
63+
$enumsPath = "$PSScriptRoot\enums"
64+
65+
if (Test-Path -Path $enumsPath) {
66+
Get-ChildItem -Path $enumsPath -Filter '*.ps1' | where PSIsContainer -eq $false | foreach {
67+
. $_.FullName
68+
}
69+
}
70+
71+
#endregion Enums
72+
73+
#region Private
74+
75+
$privatePath = "$PSScriptRoot\private"
76+
77+
if (Test-Path -Path $privatePath) {
78+
Get-ChildItem -Path $privatePath -Filter '*.ps1' | where PSIsContainer -eq $false | foreach {
79+
. $_.FullName
80+
}
81+
}
82+
83+
#endregion Private
84+
85+
#region Public
86+
87+
$publicPath = "$PSScriptRoot\public"
88+
89+
if (Test-Path -Path $publicPath) {
90+
Get-ChildItem -Path $publicPath -Filter '*.ps1' | where PSIsContainer -eq $false | foreach {
91+
. $_.FullName
92+
}
93+
}
94+
95+
#endregion Public
96+
97+
#region Completers
98+
99+
$completersPath = "$PSScriptRoot\completers"
100+
101+
if (Test-Path -Path $completersPath) {
102+
Get-ChildItem -Path $completersPath -Filter '*.ps1' | where PSIsContainer -eq $false | foreach {
103+
. $_.FullName
104+
}
105+
}
106+
107+
#region Completers
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<#
2+
.SYNOPSIS
3+
A simple PowerShell class for basic arithmetic operations.
4+
5+
.DESCRIPTION
6+
This class provides basic arithmetic functionality including addition and subtraction.
7+
It demonstrates PowerShell class implementation within the module template.
8+
#>
9+
class SimpleCalculator {
10+
[int] $LastResult
11+
12+
SimpleCalculator() {
13+
$this.LastResult = 0
14+
}
15+
16+
[int] Add([int] $a, [int] $b) {
17+
$this.LastResult = $a + $b
18+
return $this.LastResult
19+
}
20+
21+
[int] Subtract([int] $a, [int] $b) {
22+
$this.LastResult = $a - $b
23+
return $this.LastResult
24+
}
25+
26+
[int] GetLastResult() {
27+
return $this.LastResult
28+
}
29+
}

0 commit comments

Comments
 (0)