Skip to content

Commit

Permalink
[Feature]: Initial release
Browse files Browse the repository at this point in the history
  • Loading branch information
webalexeu authored May 31, 2024
1 parent 5afae9c commit 9e93ed7
Show file tree
Hide file tree
Showing 17 changed files with 312 additions and 279 deletions.
6 changes: 6 additions & 0 deletions .github/linters/.jscpd.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"ignore": [
"**/.github/**",
"**/PSWinBGP/**"
]
}
13 changes: 11 additions & 2 deletions .github/linters/.markdown-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,18 @@
###############
# Rules by id #
###############

MD004: false # Unordered list style
MD007:
indent: 2 # Unordered list indentation
MD013:
line_length: 808 # Line length
MD026:
punctuation: ".,;:!。,;:" # List of not allowed
MD029: false # Ordered list item prefix
MD033: false # Allow inline HTML
MD036: false # Emphasis used instead of a heading

#################
# Rules by tags #
#################

blank_lines: false # Error on blank lines
5 changes: 4 additions & 1 deletion .github/linters/.powershell-psscriptanalyzer.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@
# 'Warning'
#)
#IncludeDefaultRules=${true}
#ExcludeRules = @()
ExcludeRules = @(
'PSMissingModuleManifestField',
'PSReviewUnusedParameter'
)
#IncludeRules = @(
# 'PSAvoidUsingWriteHost',
# 'MyCustomRuleName'
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/Process-PSModule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,6 @@ permissions:
jobs:
Process-PSModule:
uses: PSModule/Process-PSModule/.github/workflows/workflow.yml@v1
secrets: inherit
#secrets: inherit
secrets:
APIKey: ${{ secrets.APIKEY }}
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2024 PSModule
Copyright (c) 2024 Webalex System

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
162 changes: 59 additions & 103 deletions src/PSWinBGP.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -3,127 +3,83 @@
#

@{
# Script module or binary module file associated with this manifest.
RootModule = 'PSWinBGP.psm1'

# Script module or binary module file associated with this manifest.
RootModule = 'PSWinBGP.psm1'
# Version number of this module.
ModuleVersion = '1.0.0'

# Version number of this module.
ModuleVersion = '0.1.0'
# Supported PSEditions
CompatiblePSEditions = @(
'PSEdition_Desktop',
'PSEdition_Core',
'Windows',
'Linux',
'MacOS'
)

# Supported PSEditions
CompatiblePSEditions = @('PSEdition_Desktop','PSEdition_Core','Windows','Linux','MacOS')
# ID used to uniquely identify this module
GUID = 'a7c4be44-95a4-45d3-bcb3-c9f3deb1d7d4'

# ID used to uniquely identify this module
GUID = 'a7c4be44-95a4-45d3-bcb3-c9f3deb1d7d4'
# Author of this module
Author = 'Alexandre JARDON'

# Author of this module
Author = 'Alexandre JARDON'
# Company or vendor of this module
CompanyName = 'Webalex System'

# Company or vendor of this module
CompanyName = 'Webalex System'
# Copyright statement for this module
# Copyright = '(c) author. All rights reserved.'

# Copyright statement for this module
Copyright = '(c) webalexeu. All rights reserved.'
# Description of the functionality provided by this module
Description = 'WinBGP Remote Management'

# Description of the functionality provided by this module
Description = 'WinBGP Remote Management'
# Minimum version of the PowerShell engine required by this module
PowerShellVersion = '5.1'

# Minimum version of the PowerShell engine required by this module
PowerShellVersion = '5.1'
# 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.
FunctionsToExport = @(
'Get-WinBGPRoute',
'Start-WinBGPRoute',
'Stop-WinBGPRoute',
'Start-WinBGPRouteMaintenance',
'Stop-WinBGPRouteMaintenance'
)

# Name of the PowerShell host required by this module
# PowerShellHostName = ''
# 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.
PrivateData = @{
PSData = @{
# Tags applied to this module. These help with module discovery in online galleries.
Tags = @('winbgp', 'bgp')

# Minimum version of the PowerShell host required by this module
# PowerShellHostVersion = ''
# A URL to the license for this module.
LicenseUri = 'https://github.com/webalexeu/pswinbgp/blob/master/LICENSE'

# Minimum version of Microsoft .NET Framework required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
# DotNetFrameworkVersion = ''
# A URL to the main website for this project.
ProjectUri = 'https://github.com/webalexeu/pswinbgp'

# Minimum version of the common language runtime (CLR) required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
# ClrVersion = ''
# A URL to an icon representing this module.
# IconUri = ''

# Processor architecture (None, X86, Amd64) required by this module
# ProcessorArchitecture = ''
# ReleaseNotes of this module
# ReleaseNotes = ''

# Modules that must be imported into the global environment prior to importing this module
# RequiredModules = @()
# Prerelease string of this module
# Prerelease = ''

# Assemblies that must be loaded prior to importing this module
# RequiredAssemblies = @()
# Flag to indicate whether the module requires explicit user acceptance for install/update/save
RequireLicenseAcceptance = $false

# Script files (.ps1) that are run in the caller's environment prior to importing this module.
# ScriptsToProcess = @()
# External dependent modules of this module
# ExternalModuleDependencies = @()

# Type files (.ps1xml) to be loaded when importing this module
# TypesToProcess = @()
} # End of PSData hashtable
} # End of PrivateData hashtable

# Format files (.ps1xml) to be loaded when importing this module
# FormatsToProcess = @()

# Modules to import as nested modules of the module specified in RootModule/ModuleToProcess
# NestedModules = @()

# 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.
FunctionsToExport = @('Get-WinBGPRoute','Start-WinBGPRoute','Stop-WinBGPRoute','Start-WinBGPRouteMaintenance','Stop-WinBGPRouteMaintenance')

# 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.
# CmdletsToExport = '*'

# Variables to export from this module
# VariablesToExport = '*'

# 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.
# AliasesToExport = '*'

# DSC resources to export from this module
# DscResourcesToExport = @()

# List of all modules packaged with this module
# ModuleList = @()

# List of all files packaged with this module
# FileList = @()

# 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.
PrivateData = @{

PSData = @{

# Tags applied to this module. These help with module discovery in online galleries.
Tags = @('winbgp','bgp')

# A URL to the license for this module.
LicenseUri = 'https://github.com/webalexeu/pswinbgp/blob/master/LICENSE'

# A URL to the main website for this project.
ProjectUri = 'https://github.com/webalexeu/pswinbgp'

# A URL to an icon representing this module.
# IconUri = ''

# ReleaseNotes of this module
# ReleaseNotes = ''

# Prerelease string of this module
# Prerelease = ''

# Flag to indicate whether the module requires explicit user acceptance for install/update/save
RequireLicenseAcceptance = $false

# External dependent modules of this module
# ExternalModuleDependencies = @()

} # End of PSData hashtable

} # End of PrivateData hashtable

# HelpInfo URI of this module
# HelpInfoURI = ''

# Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix.
# DefaultCommandPrefix = ''
# HelpInfo URI of this module
# HelpInfoURI = ''

# Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix.
# DefaultCommandPrefix = ''
}


33 changes: 24 additions & 9 deletions src/PSWinBGP.psm1
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Dot source public/private functions
$public = @(Get-ChildItem -Path (Join-Path -Path $PSScriptRoot -ChildPath 'Public/*.ps1') -Recurse -ErrorAction Stop)
$public = @(Get-ChildItem -Path (Join-Path -Path $PSScriptRoot -ChildPath 'Public/*.ps1') -Recurse -ErrorAction Stop)
$private = @(Get-ChildItem -Path (Join-Path -Path $PSScriptRoot -ChildPath 'Private/*.ps1') -Recurse -ErrorAction Stop)
foreach ($import in @($public + $private)) {
try {
Expand All @@ -13,24 +13,39 @@ Export-ModuleMember -Function $public.Basename

# Route Argument Completer
$ArgumentCompleterBlock = {
param($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameters)
param(
$commandName,
$parameterName,
$wordToComplete,
$commandAst,
$fakeBoundParameters
)

# Dynamically generate routes array
if ($FakeBoundParameters.ComputerName) {
[Array] $routes = (Get-WinBGPRoute -ComputerName $FakeBoundParameters.ComputerName)
} else {
[Array] $routes = (Get-WinBGPRoute)
}
# Return routes as arguments (Intellisense)
# Return routes as arguments (IntelliSense)
$routes | ForEach-Object {
New-Object -Type System.Management.Automation.CompletionResult -ArgumentList $_.Name,
#"$($_.ComputerName)_$($_.Name)",
"$(if ($_.ComputerName){"ComputerName: '$($_.ComputerName)' - RouteName: '$($_.Name)'"}else{$_.Name})",
"ParameterValue",
"$(if ($_.ComputerName){"ComputerName: '$($_.ComputerName)' - "})Network: '$($_.Network)' - Status: '$($_.Status)'"
New-Object -Type System.Management.Automation.CompletionResult -ArgumentList
$_.Name,
#"$($_.ComputerName)_$($_.Name)",
"$(if ($_.ComputerName){"ComputerName: '$($_.ComputerName)' - RouteName: '$($_.Name)'"}else{$_.Name})",
"ParameterValue",
"$(if ($_.ComputerName){"ComputerName: '$($_.ComputerName)' - "})Network: '$($_.Network)' - Status: '$($_.Status)'"
}
# To review (to avoid syntax error)
$null = $commandName
$null = $parameterName
$null = $wordToComplete
$null = $commandAst
}
Register-ArgumentCompleter -CommandName Start-WinBGPRoute,Stop-WinBGPRoute,Start-WinBGPRouteMaintenance,Stop-WinBGPRouteMaintenance -ParameterName RouteName -ScriptBlock $ArgumentCompleterBlock
Register-ArgumentCompleter `
-CommandName Start-WinBGPRoute, Stop-WinBGPRoute, Start-WinBGPRouteMaintenance, Stop-WinBGPRouteMaintenance `
-ParameterName RouteName `
-ScriptBlock $ArgumentCompleterBlock

# Declare a module-level variable
$PSWinBGP = [ordered]@{
Expand Down
Loading

0 comments on commit 9e93ed7

Please sign in to comment.