-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixes #89 - added prompt for classes
- Loading branch information
1 parent
215e499
commit 75da12f
Showing
13 changed files
with
137 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
src/Catesta/Resources/Module/src/Module/Classes/SampleClass.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<# | ||
.NOTES | ||
This class demonstrates basic class structure and functionality in PowerShell. | ||
# Create an instance of the SampleClass | ||
$person = [SampleClass]::new('John Doe', 30) | ||
# Call the Greet method | ||
$message = $person.Greet() | ||
Write-Output $message | ||
# Increment the age and output a birthday message | ||
$person.HaveBirthday() | ||
# Access the properties | ||
Write-Output "Name: $($person.Name)" | ||
Write-Output "Age: $($person.Age)" | ||
#> | ||
class SampleClass { | ||
[string]$Name | ||
[int]$Age | ||
|
||
SampleClass([string]$Name, [int]$Age) { | ||
$this.Name = $Name | ||
$this.Age = $Age | ||
} | ||
|
||
[string]Greet() { | ||
return "Hello, my name is $($this.Name) and I am $($this.Age) years old." | ||
} | ||
|
||
[string]HaveBirthday() { | ||
$this.Age++ | ||
return "Happy Birthday $($this.Name)! You are now $($this.Age) years old." | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
src/Catesta/Resources/Module/src/Module/Module_Classes.psm1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# this psm1 is for local testing and development use only | ||
|
||
# dot source the parent import for local development variables | ||
. $PSScriptRoot\Imports.ps1 | ||
|
||
# discover all ps1 file(s) in Public and Private paths | ||
|
||
$itemSplat = @{ | ||
Filter = '*.ps1' | ||
Recurse = $true | ||
ErrorAction = 'Stop' | ||
} | ||
try { | ||
$public = @(Get-ChildItem -Path "$PSScriptRoot\Public" @itemSplat) | ||
$private = @(Get-ChildItem -Path "$PSScriptRoot\Private" @itemSplat) | ||
$classes = @(Get-ChildItem -Path "$PSScriptRoot\Classes" @itemSplat) | ||
} | ||
catch { | ||
Write-Error $_ | ||
throw 'Unable to get get file information from Public/Private/Classes src.' | ||
} | ||
|
||
# dot source all .ps1 file(s) found | ||
foreach ($file in @($public + $private + $classes)) { | ||
try { | ||
. $file.FullName | ||
} | ||
catch { | ||
throw ('Unable to dot source {0}' -f $file.FullName) | ||
} | ||
} | ||
|
||
# export all public functions | ||
Export-ModuleMember -Function $public.Basename |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.