• Stars
    star
    151
  • Rank 246,057 (Top 5 %)
  • Language
    C#
  • License
    Other
  • Created over 7 years ago
  • Updated over 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Collection of editor commands for use in PowerShell Editor Services.

EditorServicesCommandSuite

EditorServicesCommandSuite is a PowerShell module of editor commands to assist with editing PowerShell scripts in VSCode.

This project adheres to the Contributor Covenant code of conduct. By participating, you are expected to uphold this code. Please report unacceptable behavior to [email protected].

Features

  • Generate markdown help using PlatyPS
  • Implement a .NET interface with PowerShell classes
  • Module maintenance like adding commands to the manifest
  • Suppress PSScriptAnalyzer rules
  • Splat commands

Documentation

Check out our documentation for a full list of editor commands and what they do.

Demo

short-demo

Installation

Install from the Gallery

Install-Module EditorServicesCommandSuite -Scope CurrentUser -AllowPrerelease -RequiredVersion 1.0.0-beta4

Add to Profile (Optional)

# Place this in your VSCode profile
Import-CommandSuite
# Or copy this command and paste it into the integrated console
psedit $profile;$psEditor|% g*t|% c*e|% i* "Import-CommandSuite`n" 1 1 1 1

Importing

Import-CommandSuite

This function will import all editor commands in the module and initialize event handlers.

Using Editor Commands

Check out the Using Editor Commands guide in the PowerShell Editor Services documentation. I also highly recommend setting up a hotkey for the editor command menu. Here is mine as an example.

{ "key": "ctrl+shift+c",   "command": "PowerShell.ShowAdditionalCommands",
                              "when": "editorLangId == 'powershell'" },

Settings

This module is built to be compatible with the project structure from my Plaster template SSPowerShellBoilerplate. If you prefer a different structure you can configure the paths with a workspace settings file. You can create a default settings file in the current workspace with the New-ESCSSettingsFile function.

Included Commands

All commands unless otherwise noted target the closest relevant expression.

Function Name Editor Command Name Description
Add-CommandToManifest Add Closest Function To Manifest Add a function to the manifest fields ExportedFunctions and FileList
Add-ModuleQualification Add Module Name to Closest Command Infers the origin module of the command closest to the cursor and prepends the module name
Add-PinvokeMethod Insert Pinvoke Method Definition Searches the pinvoke.net web service for a matching function and creates a Add-Type expression with the signature
ConvertTo-FunctionDefinition Create New Function From Selection Generate a function definition expression from current selection
ConvertTo-LocalizationString Add Closest String to Localization File Replaces a string expression with a variable that references a localization file, and adds the string to that file
ConvertTo-MarkdownHelp Generate Markdown from Closest Function Generate markdown using PlatyPS, add the markdown file to your docs folder, and replace the comment help with an external help file comment.
ConvertTo-SplatExpression Convert Command to Splat Expression Create a splat hashtable variable from named parameters in a command and replace the named parameters with a a splat expression.
Expand-Expression Expand Selection Text to Output Invoke the currently selected text and replace it with the result.
Expand-MemberExpression Expand Member Expression Expands the closest member expression of a non-public member to a reflection statement to access it. For public methods it will also expand to include parameter name comments.
Expand-TypeImplementation Expand Closest Type to Implementation Replace a type expression with a class that implements the .NET class. Includes methods that are required to be implemented.
Remove-Semicolon Remove cosmetic semicolons Remove semi-colons that are at the end of a line, not in a string, and not a part of a property definition in a class.
Set-HangingIndent Set Selection Indent to Selection Start Indent selected lines to the start of the selection.
Set-RuleSuppression Suppress Closest Analyzer Rule Violation Create a SuppressMessage attribute for the closest rule violation and place it either above the violation if supported or above the param block.
Set-UsingStatementOrder Sort Using Statements Sort using statements by type (assembly, module, or namespace) and alphabetically

Contributions Welcome!

We would love to incorporate community contributions into this project. If you would like to contribute code, documentation, tests, or bug reports, please read our Contribution Guide to learn more.

More Repositories

1

ClassExplorer

Discover the API you need with ease
C#
90
star
2

PSLambda

A runtime compiler for PowerShell ScriptBlock objects.
C#
61
star
3

ImpliedReflection

Access non-public types and type members as if they were public.
C#
42
star
4

dotfiles

PowerShell
34
star
5

EditorAstProvider

Browse script structure like a File System
PowerShell
25
star
6

ScriptBlockDisassembler

See generated code for a ScriptBlock
C#
17
star
7

ILAssembler

ILAsm-like DSL for PowerShell
C#
16
star
8

MockingPSClassesPoC

A proof of concept for mocking class methods created in PowerShell
PowerShell
11
star
9

PSStringTemplate

Create and render templates using the StringTemplate template engine.
C#
11
star
10

PSSyntaxRewriter

PowerShell abstract syntax tree rewriter library
C#
11
star
11

PSWriteline

Collection of PSReadline key handlers to add more "editor-like" features.
PowerShell
10
star
12

NewXmlDocument

Dynamic DSL for creating XML files
PowerShell
9
star
13

SSPowerShellBoilerplate

An opinionated Plaster template for jump starting Open Source PowerShell projects.
PowerShell
9
star
14

GetClrCallStack

Get the call stack of every thread in the target process
PowerShell
8
star
15

EditorServicesProcess

Interact with the integrated console outside of Editor Services.
PowerShell
7
star
16

PSClassHelpExample

Example of existing support for classes in the PowerShell help system.
PowerShell
7
star
17

PSESHelperLibrary

PowerShell
5
star
18

UnixConsoleEcho

C++
3
star
19

psudad

Rust
3
star
20

PSValueWildcard

C#
3
star
21

PSOutPager

C#
2
star
22

ClrDebug

Cross platform wrappers for the ICorDebug API using calli.
C#
2
star
23

AstPolyfillExample

How to reference new AST types while targeting PowerShellStandard
C#
2
star
24

terminal-input

A very simple VSCode extension for setting key bindings that send custom input to the active terminal.
TypeScript
2
star
25

ETG-GunBinds

Enter the Gungeon mod for a better gun switching experience
C#
1
star
26

PowerShellEditorServices.Atom

PowerShell
1
star
27

MetadataAssembly

A reflection only implementation of the common System.Reflection types using API's from the System.Reflection.Metadata namespace.
C#
1
star