latest WIP
This commit is contained in:
3
Sublime/PowerShell/.gitignore
vendored
Normal file
3
Sublime/PowerShell/.gitignore
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
*.pyc
|
||||
*.cache
|
||||
*.sublime-project
|
16
Sublime/PowerShell/.hgignore
Normal file
16
Sublime/PowerShell/.hgignore
Normal file
@@ -0,0 +1,16 @@
|
||||
syntax: glob
|
||||
|
||||
dist/
|
||||
|
||||
*.hgignore
|
||||
*.hgtags
|
||||
|
||||
*.pyc
|
||||
|
||||
*.cache
|
||||
*.sublime-project
|
||||
*.sublime-workspace
|
||||
|
||||
MANIFEST
|
||||
|
||||
_.txt
|
7
Sublime/PowerShell/LICENSE.txt
Normal file
7
Sublime/PowerShell/LICENSE.txt
Normal file
@@ -0,0 +1,7 @@
|
||||
Copyright (c) 2011 Guillermo López-Anglada
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
@@ -0,0 +1,9 @@
|
||||
<!-- See http://www.sublimetext.com/docs/snippets for more information -->
|
||||
<snippet>
|
||||
<content><![CDATA[begin { $1
|
||||
}]]></content>
|
||||
<!-- Optional: Tab trigger to activate the snippet -->
|
||||
<tabTrigger>beg</tabTrigger>
|
||||
<!-- Optional: Scope the tab trigger will be active in -->
|
||||
<scope>source.powershell</scope>
|
||||
</snippet>
|
@@ -0,0 +1,7 @@
|
||||
<snippet>
|
||||
<content><![CDATA[catch ${1:[Exception]}{
|
||||
$2
|
||||
}$0]]></content>
|
||||
<tabTrigger>catch</tabTrigger>
|
||||
<scope>source.powershell</scope>
|
||||
</snippet>
|
@@ -0,0 +1,12 @@
|
||||
<!-- See http://www.sublimetext.com/docs/snippets for more information -->
|
||||
<snippet>
|
||||
<content><![CDATA[<#
|
||||
$0
|
||||
#>]]></content>
|
||||
<!-- Optional: Tab trigger to activate the snippet -->
|
||||
<tabTrigger>comm</tabTrigger>
|
||||
<!-- Optional: Scope the tab trigger will be active in -->
|
||||
<scope>source.powershell</scope>
|
||||
<!-- Optional: Description to show in the menu -->
|
||||
<description>Comment block</description>
|
||||
</snippet>
|
@@ -0,0 +1,10 @@
|
||||
<!-- See http://www.sublimetext.com/docs/snippets for more information -->
|
||||
<snippet>
|
||||
<content><![CDATA[elseif ($1) {
|
||||
$2
|
||||
}]]></content>
|
||||
<!-- Optional: Tab trigger to activate the snippet -->
|
||||
<tabTrigger>elif</tabTrigger>
|
||||
<!-- Optional: Scope the tab trigger will be active in -->
|
||||
<scope>source.powershell</scope>
|
||||
</snippet>
|
@@ -0,0 +1,8 @@
|
||||
<!-- See http://www.sublimetext.com/docs/snippets for more information -->
|
||||
<snippet>
|
||||
<content><![CDATA[elseif ($1) { $2 }]]></content>
|
||||
<!-- Optional: Tab trigger to activate the snippet -->
|
||||
<tabTrigger>elifi</tabTrigger>
|
||||
<!-- Optional: Scope the tab trigger will be active in -->
|
||||
<scope>source.powershell</scope>
|
||||
</snippet>
|
@@ -0,0 +1,10 @@
|
||||
<!-- See http://www.sublimetext.com/docs/snippets for more information -->
|
||||
<snippet>
|
||||
<content><![CDATA[else {
|
||||
$1
|
||||
}]]></content>
|
||||
<!-- Optional: Tab trigger to activate the snippet -->
|
||||
<tabTrigger>else</tabTrigger>
|
||||
<!-- Optional: Scope the tab trigger will be active in -->
|
||||
<scope>source.powershell</scope>
|
||||
</snippet>
|
@@ -0,0 +1,8 @@
|
||||
<!-- See http://www.sublimetext.com/docs/snippets for more information -->
|
||||
<snippet>
|
||||
<content><![CDATA[else { $1 }]]></content>
|
||||
<!-- Optional: Tab trigger to activate the snippet -->
|
||||
<tabTrigger>elsei</tabTrigger>
|
||||
<!-- Optional: Scope the tab trigger will be active in -->
|
||||
<scope>source.powershell</scope>
|
||||
</snippet>
|
@@ -0,0 +1,9 @@
|
||||
<!-- See http://www.sublimetext.com/docs/snippets for more information -->
|
||||
<snippet>
|
||||
<content><![CDATA[end { $1
|
||||
}]]></content>
|
||||
<!-- Optional: Tab trigger to activate the snippet -->
|
||||
<tabTrigger>end</tabTrigger>
|
||||
<!-- Optional: Scope the tab trigger will be active in -->
|
||||
<scope>source.powershell</scope>
|
||||
</snippet>
|
10
Sublime/PowerShell/Snippets/(fil) new filter.sublime-snippet
Normal file
10
Sublime/PowerShell/Snippets/(fil) new filter.sublime-snippet
Normal file
@@ -0,0 +1,10 @@
|
||||
<!-- See http://www.sublimetext.com/docs/snippets for more information -->
|
||||
<snippet>
|
||||
<content><![CDATA[filter ${1:filterName} {
|
||||
$2
|
||||
}]]></content>
|
||||
<!-- Optional: Tab trigger to activate the snippet -->
|
||||
<tabTrigger>fil</tabTrigger>
|
||||
<!-- Optional: Scope the tab trigger will be active in -->
|
||||
<scope>source.powershell</scope>
|
||||
</snippet>
|
@@ -0,0 +1,7 @@
|
||||
<snippet>
|
||||
<content><![CDATA[finally {
|
||||
$1
|
||||
}$0]]></content>
|
||||
<tabTrigger>fin</tabTrigger>
|
||||
<scope>source.powershell</scope>
|
||||
</snippet>
|
@@ -0,0 +1,10 @@
|
||||
<!-- See http://www.sublimetext.com/docs/snippets for more information -->
|
||||
<snippet>
|
||||
<content><![CDATA[function ${1:funcName} {
|
||||
$2
|
||||
}]]></content>
|
||||
<!-- Optional: Tab trigger to activate the snippet -->
|
||||
<tabTrigger>fun</tabTrigger>
|
||||
<!-- Optional: Scope the tab trigger will be active in -->
|
||||
<scope>source.powershell</scope>
|
||||
</snippet>
|
@@ -0,0 +1,10 @@
|
||||
<!-- See http://www.sublimetext.com/docs/snippets for more information -->
|
||||
<snippet>
|
||||
<content><![CDATA[@'
|
||||
$1
|
||||
'@]]></content>
|
||||
<!-- Optional: Tab trigger to activate the snippet -->
|
||||
<tabTrigger>here</tabTrigger>
|
||||
<!-- Optional: Scope the tab trigger will be active in -->
|
||||
<scope>source.powershell</scope>
|
||||
</snippet>
|
@@ -0,0 +1,10 @@
|
||||
<!-- See http://www.sublimetext.com/docs/snippets for more information -->
|
||||
<snippet>
|
||||
<content><![CDATA[@"
|
||||
$1
|
||||
"@]]></content>
|
||||
<!-- Optional: Tab trigger to activate the snippet -->
|
||||
<tabTrigger>hhere</tabTrigger>
|
||||
<!-- Optional: Scope the tab trigger will be active in -->
|
||||
<scope>source.powershell</scope>
|
||||
</snippet>
|
10
Sublime/PowerShell/Snippets/(if) if {...}.sublime-snippet
Normal file
10
Sublime/PowerShell/Snippets/(if) if {...}.sublime-snippet
Normal file
@@ -0,0 +1,10 @@
|
||||
<!-- See http://www.sublimetext.com/docs/snippets for more information -->
|
||||
<snippet>
|
||||
<content><![CDATA[if ($1) {
|
||||
$2
|
||||
}]]></content>
|
||||
<!-- Optional: Tab trigger to activate the snippet -->
|
||||
<tabTrigger>if</tabTrigger>
|
||||
<!-- Optional: Scope the tab trigger will be active in -->
|
||||
<scope>source.powershell</scope>
|
||||
</snippet>
|
@@ -0,0 +1,13 @@
|
||||
<!-- See http://www.sublimetext.com/docs/snippets for more information -->
|
||||
<snippet>
|
||||
<content><![CDATA[if ($1) {
|
||||
$2
|
||||
}
|
||||
else {
|
||||
$3
|
||||
}]]></content>
|
||||
<!-- Optional: Tab trigger to activate the snippet -->
|
||||
<tabTrigger>ifelse</tabTrigger>
|
||||
<!-- Optional: Scope the tab trigger will be active in -->
|
||||
<scope>source.powershell</scope>
|
||||
</snippet>
|
@@ -0,0 +1,8 @@
|
||||
<!-- See http://www.sublimetext.com/docs/snippets for more information -->
|
||||
<snippet>
|
||||
<content><![CDATA[if ($1) { $2 }]]></content>
|
||||
<!-- Optional: Tab trigger to activate the snippet -->
|
||||
<tabTrigger>ifi</tabTrigger>
|
||||
<!-- Optional: Scope the tab trigger will be active in -->
|
||||
<scope>source.powershell</scope>
|
||||
</snippet>
|
@@ -0,0 +1,8 @@
|
||||
<!-- See http://www.sublimetext.com/docs/snippets for more information -->
|
||||
<snippet>
|
||||
<content><![CDATA[${1:\$mydocs} = [environment]::GetFolderPath([environment+specialfolder]::MyDocuments)]]></content>
|
||||
<!-- Optional: Tab trigger to activate the snippet -->
|
||||
<tabTrigger>mydocs</tabTrigger>
|
||||
<!-- Optional: Scope the tab trigger will be active in -->
|
||||
<scope>source.powershell</scope>
|
||||
</snippet>
|
@@ -0,0 +1,9 @@
|
||||
<!-- See http://www.sublimetext.com/docs/snippets for more information -->
|
||||
<snippet>
|
||||
<content><![CDATA[process { $1
|
||||
}]]></content>
|
||||
<!-- Optional: Tab trigger to activate the snippet -->
|
||||
<tabTrigger>proc</tabTrigger>
|
||||
<!-- Optional: Scope the tab trigger will be active in -->
|
||||
<scope>source.powershell</scope>
|
||||
</snippet>
|
@@ -0,0 +1,8 @@
|
||||
<!-- See http://www.sublimetext.com/docs/snippets for more information -->
|
||||
<snippet>
|
||||
<content><![CDATA[\$($1)]]></content>
|
||||
<!-- Optional: Tab trigger to activate the snippet -->
|
||||
<tabTrigger>sub</tabTrigger>
|
||||
<!-- Optional: Scope the tab trigger will be active in -->
|
||||
<scope>source.powershell</scope>
|
||||
</snippet>
|
@@ -0,0 +1,9 @@
|
||||
<!-- See http://www.sublimetext.com/docs/snippets for more information -->
|
||||
<snippet>
|
||||
<content><![CDATA[\$tmpfile = [io.path]::GetTempFileName()
|
||||
]]></content>
|
||||
<!-- Optional: Tab trigger to activate the snippet -->
|
||||
<tabTrigger>tmp</tabTrigger>
|
||||
<!-- Optional: Scope the tab trigger will be active in -->
|
||||
<scope>source.powershell</scope>
|
||||
</snippet>
|
@@ -0,0 +1,7 @@
|
||||
<snippet>
|
||||
<content><![CDATA[try {
|
||||
$1
|
||||
}$0]]></content>
|
||||
<tabTrigger>try</tabTrigger>
|
||||
<scope>source.powershell</scope>
|
||||
</snippet>
|
@@ -0,0 +1,7 @@
|
||||
<snippet>
|
||||
<content><![CDATA[@'
|
||||
$0
|
||||
'@]]></content>
|
||||
<tabTrigger>hered</tabTrigger>
|
||||
<scope>source.powershell</scope>
|
||||
</snippet>
|
@@ -0,0 +1,7 @@
|
||||
<snippet>
|
||||
<content><![CDATA[@"
|
||||
$0
|
||||
"@]]></content>
|
||||
<tabTrigger>heredd</tabTrigger>
|
||||
<scope>source.powershell</scope>
|
||||
</snippet>
|
@@ -0,0 +1,5 @@
|
||||
<snippet>
|
||||
<content><![CDATA[\$script:thisDir = split-path \$MyInvocation.MyCommand.Path -parent]]></content>
|
||||
<tabTrigger>thisdir</tabTrigger>
|
||||
<scope>source.powershell</scope>
|
||||
</snippet>
|
17
Sublime/PowerShell/Snippets/Powershell.sublime-completions
Normal file
17
Sublime/PowerShell/Snippets/Powershell.sublime-completions
Normal file
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"scope": "source.powershell",
|
||||
|
||||
"completions": [
|
||||
{ "trigger": "dict", "contents": "@{$1$0}" },
|
||||
{ "trigger": "arr", "contents": "@($0)" },
|
||||
{ "trigger": "req", "contents": "#requires -$0" },
|
||||
{ "trigger": "reqp", "contents": "#requires -pssnapin $0" },
|
||||
{ "trigger": "reqv", "contents": "#requires -version ${0:2}" },
|
||||
{ "trigger": "void", "contents": "[void] ($1)$0" },
|
||||
{ "trigger": "sb", "contents": "\\${$1}$0" },
|
||||
{ "trigger": "wd", "contents": "write-debug -message \"$1\"$0" },
|
||||
{ "trigger": "wh", "contents": "write-host \"$1\"" },
|
||||
{ "trigger": "ww", "contents": "write-warning $0" },
|
||||
{ "trigger": "param", "contents": "param(\\$${1:paramName})" }
|
||||
]
|
||||
}
|
@@ -0,0 +1,5 @@
|
||||
<snippet>
|
||||
<content><![CDATA[set-psdebug ${1:-${2:Step}}$0]]></content>
|
||||
<tabTrigger>sd</tabTrigger>
|
||||
<scope>source.powershell</scope>
|
||||
</snippet>
|
42
Sublime/PowerShell/Support/Comments.tmPreferences
Normal file
42
Sublime/PowerShell/Support/Comments.tmPreferences
Normal file
@@ -0,0 +1,42 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>Comments</string>
|
||||
<key>scope</key>
|
||||
<string>source.powershell</string>
|
||||
<key>settings</key>
|
||||
<dict>
|
||||
<key>shellVariables</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>TM_COMMENT_START</string>
|
||||
<key>value</key>
|
||||
<string># </string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>TM_COMMENT_START_2</string>
|
||||
<key>value</key>
|
||||
<string><#</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>TM_COMMENT_END_2</string>
|
||||
<key>value</key>
|
||||
<string>#></string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>TM_COMMENT_DISABLE_INDENT_2</string>
|
||||
<key>value</key>
|
||||
<string>yes</string>
|
||||
</dict>
|
||||
</array>
|
||||
</dict>
|
||||
<key>uuid</key>
|
||||
<string>06532840-4879-11df-9879-0800200c9a66</string>
|
||||
</dict>
|
||||
</plist>
|
4
Sublime/PowerShell/Support/Powershell.sublime-build
Normal file
4
Sublime/PowerShell/Support/Powershell.sublime-build
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"cmd": ["powershell.exe", "-noprofile", "-file", "$file"],
|
||||
"selector": "source.powershell"
|
||||
}
|
392
Sublime/PowerShell/Support/PowershellSyntax.JSON-tmLanguage
Normal file
392
Sublime/PowerShell/Support/PowershellSyntax.JSON-tmLanguage
Normal file
@@ -0,0 +1,392 @@
|
||||
{
|
||||
"fileTypes": ["ps1", "psm1", "psd1"],
|
||||
"name": "Powershell v2",
|
||||
"patterns": [
|
||||
{
|
||||
"begin": "<#",
|
||||
"beginCaptures": {
|
||||
"0": {
|
||||
"name": "punctuation.start.definition.comment.block.powershell"
|
||||
}
|
||||
},
|
||||
"end": "#>",
|
||||
"endCaptures": {
|
||||
"0": {
|
||||
"name": "punctuation.end.definition.comment.block.powershell"
|
||||
}
|
||||
},
|
||||
"name": "comment.block.powershell",
|
||||
"patterns": [
|
||||
{
|
||||
"include": "#commentEmbeddedDocs"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"begin": "(?<![\\\\-])#",
|
||||
"end": "$",
|
||||
"name": "comment.line.powershell",
|
||||
"patterns": [
|
||||
{
|
||||
"include": "#commentEmbeddedDocs"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"include": "#variable"
|
||||
},
|
||||
{
|
||||
"include": "#scriptblock"
|
||||
},
|
||||
{
|
||||
"begin": "(?<!(?<!`)\")\"",
|
||||
"end": "\"(?!\")",
|
||||
"name": "string.quoted.double.powershell",
|
||||
"patterns": [
|
||||
{
|
||||
"include": "#variable"
|
||||
},
|
||||
{
|
||||
"include": "#doubleQuotedStringEscapes"
|
||||
},
|
||||
{
|
||||
"include": "#interpolation"
|
||||
},
|
||||
{
|
||||
"match": "`\\s*$",
|
||||
"name": "keyword.other.powershell"
|
||||
}
|
||||
]
|
||||
},
|
||||
{ "include": "#doubleQuotedStringEscapes",
|
||||
"comment": "Needed to parse stuff correctly in 'argument mode'. (See about_parsing.)"
|
||||
},
|
||||
{
|
||||
"begin": "(?<!')'",
|
||||
"end": "'(?!')",
|
||||
"name": "string.quoted.single.powershell",
|
||||
"patterns": [
|
||||
{
|
||||
"match": "''",
|
||||
"name": "constant.character.escape.powershell"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"begin": "@\"$",
|
||||
"end": "^\"@",
|
||||
"name": "string.quoted.double.heredoc.powershell",
|
||||
"patterns": [
|
||||
{
|
||||
"include": "#interpolation"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"begin": "@\\(",
|
||||
"captures": {
|
||||
"0": {
|
||||
"name": "keyword.other.powershell"
|
||||
}
|
||||
},
|
||||
"end": "\\)",
|
||||
"name": "meta.group.array-expression.powershell",
|
||||
"patterns": [
|
||||
{
|
||||
"include": "$self"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"begin": "\\$\\(",
|
||||
"captures": {
|
||||
"0": {
|
||||
"name": "keyword.other.powershell"
|
||||
}
|
||||
},
|
||||
"comment": "TODO: move to repo; make recursive.",
|
||||
"end": "\\)",
|
||||
"name": "meta.group.complex.subexpression.powershell",
|
||||
"patterns": [
|
||||
{
|
||||
"include": "$self"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"begin": "@'$",
|
||||
"end": "^'@$",
|
||||
"name": "string.quoted.double.heredoc.powershell"
|
||||
},
|
||||
{
|
||||
"include": "#numericConstant"
|
||||
},
|
||||
{
|
||||
"match": "-([lg][te]|[ci]?(eq|ne))",
|
||||
"name": "keyword.operator.logical.powershell"
|
||||
},
|
||||
{
|
||||
"include": "#PSDefaults"
|
||||
},
|
||||
{
|
||||
"match": "(?i:[a-z][a-z0-9]+-[a-z][a-z0-9]+)",
|
||||
"name": "support.function.powershell"
|
||||
},
|
||||
{
|
||||
"match": "\\b(?i:if|else|elseif|switch|while|default|try|finally|catch|for|do|until|break|continue|foreach|return|filter|in|trap|throw|param|begin|process|end|function|global|local|private|script|contained)\\b",
|
||||
"name": "keyword.control.powershell"
|
||||
},
|
||||
{
|
||||
"match": "-(?i:(?:[ic]?eq|ne|[gl][te]|(?:not)?(?:like|match|contains)|replace)|is(?:not)?|as|and|or|band|bor|not|f)\\b",
|
||||
"name": "keyword.operator.comparison.powershell"
|
||||
},
|
||||
{
|
||||
"match": "-(?i:and|or|not)|!",
|
||||
"name": "keyword.operator.logical.powershell"
|
||||
},
|
||||
{
|
||||
"match": "-(?i:f|band|bor|-bnot)\\b",
|
||||
"name": "keyword.operator.bitwise.powershell"
|
||||
},
|
||||
{
|
||||
"match": "-f\\b",
|
||||
"name": "keyword.operator.string-format.powershell"
|
||||
},
|
||||
{
|
||||
"match": "[+%*/-]?=|[+/*%-]",
|
||||
"name": "keyword.operator.assignment.powershell"
|
||||
},
|
||||
{
|
||||
"match": "2>&1|>>|>|<<|<|>|>\\||2>|2>>|1>>",
|
||||
"name": "keyword.operator.redirection.powershell"
|
||||
},
|
||||
{
|
||||
"match": "\\|{2}|&{2}|;",
|
||||
"name": "keyword.other.statement-separator.powershell"
|
||||
},
|
||||
{
|
||||
"match": "&|(?<!\\w)\\.(?= )|`|,|\\|",
|
||||
"name": "keyword.operator.other.powershell"
|
||||
}
|
||||
],
|
||||
"repository": {
|
||||
"PSDefaults": {
|
||||
"comment": "Default commandlets in Powershell v2",
|
||||
"match": "Disconnect-(WSMan)|Exit-(PSSession)|Copy-(Item|ItemProperty)|Resolve-(Path)|Group-(Object)|Remove-(Computer|Event|EventLog|Item|ItemProperty|Job|Module|PSBreakpoint|PSDrive|PSSession|PSSnapin|Variable|WmiObject|WSManInstance)|Unregister-(Event|PSSessionConfiguration)|Tee-(Object)|Pop-(Location)|Set-(Acl|Alias|AuthenticodeSignature|Content|Date|ExecutionPolicy|Item|ItemProperty|Location|PSBreakpoint|PSDebug|PSSessionConfiguration|Service|StrictMode|TraceSource|Variable|WmiInstance|WSManInstance|WSManQuickConfig)|Format-(Custom|List|Table|Wide)|Invoke-(Command|Expression|History|Item|WmiMethod|WSManAction)|Export-(Alias|Clixml|Console|Counter|Csv|FormatData|ModuleMember|PSSession)|Update-(FormatData|List|TypeData)|Sort-(Object)|Measure-(Command|Object)|ForEach-(Object)|Connect-(WSMan)|Suspend-(Service)|ConvertFrom-(Csv|SecureString|StringData)|Where-(Object)|Rename-(Item|ItemProperty)|Convert-(Path)|Select-(Object|String|Xml)|Import-(Alias|Clixml|Counter|Csv|LocalizedData|Module|PSSession)|Stop-(Computer|Job|Process|Service|Transcript)|New-(Alias|Event|EventLog|Item|ItemProperty|Module|ModuleManifest|Object|PSDrive|PSSession|PSSessionOption|Service|TimeSpan|Variable|WebServiceProxy|WSManInstance|WSManSessionOption)|Resume-(Service)|Show-(EventLog)|Out-(Default|File|GridView|Host|Null|Printer|String)|Undo-(Transaction)|Trace-(Command)|Clear-(Content|EventLog|History|Item|ItemProperty|Variable)|Push-(Location)|Split-(Path)|Disable-(ComputerRestore|PSBreakpoint|PSSessionConfiguration|WSManCredSSP)|Reset-(ComputerMachinePassword)|Restore-(Computer)|ConvertTo-(Csv|Html|SecureString|Xml)|Enable-(ComputerRestore|PSBreakpoint|PSRemoting|PSSessionConfiguration|WSManCredSSP)|Join-(Path)|Register-(EngineEvent|ObjectEvent|PSSessionConfiguration|WmiEvent)|Compare-(Object)|Get-(Acl|Alias|AuthenticodeSignature|ChildItem|Command|ComputerRestorePoint|Content|Counter|Credential|Culture|Date|Event|EventLog|EventSubscriber|ExecutionPolicy|FormatData|Help|History|Host|HotFix|Item|ItemProperty|Job|Location|Member|Module|PfxCertificate|Process|PSBreakpoint|PSCallStack|PSDrive|PSProvider|PSSession|PSSessionConfiguration|PSSnapin|Random|Service|TraceSource|Transaction|UICulture|Unique|Variable|WinEvent|WmiObject|WSManCredSSP|WSManInstance)|Receive-(Job)|Move-(Item|ItemProperty)|Add-(Computer|Content|History|Member|PSSnapin|Type)|Wait-(Event|Job|Process)|Send-(MailMessage)|Read-(Host)|Complete-(Transaction)|Checkpoint-(Computer)|Debug-(Process)|Use-(Transaction)|Restart-(Computer|Service)|Write-(Debug|Error|EventLog|Host|Output|Progress|Verbose|Warning)|Test-(ComputerSecureChannel|Connection|ModuleManifest|Path|WSMan)|Start-(Job|Process|Service|Sleep|Transaction|Transcript)|Limit-(EventLog)|Enter-(PSSession)",
|
||||
"name": "support.function.builtin.powershell"
|
||||
},
|
||||
"commentEmbeddedDocs": {
|
||||
"patterns": [
|
||||
{
|
||||
"captures": {
|
||||
"1": {
|
||||
"name": "constant.string.documentation.powershell"
|
||||
},
|
||||
"2": {
|
||||
"name": "keyword.operator.documentation.powershell"
|
||||
}
|
||||
},
|
||||
"match": "(?i:\\s*(\\.)(SYNOPSIS|DESCRIPTION|EXAMPLE|INPUTS|OUTPUTS|NOTES|LINK|COMPONENT|FUNCTIONALITY))",
|
||||
"name": "comment.documentation.embedded.powershell"
|
||||
},
|
||||
{
|
||||
"captures": {
|
||||
"1": {
|
||||
"name": "constant.string.documentation.powershell"
|
||||
},
|
||||
"2": {
|
||||
"name": "keyword.operator.documentation.powershell"
|
||||
},
|
||||
"3": {
|
||||
"name": "keyword.operator.documentation.powershell"
|
||||
}
|
||||
},
|
||||
"match": "(?i:\\s*(\\.)(PARAMETER|FORWARDHELPTARGETNAME|FORWARDHELPCATEGORY|REMOTEHELPRUNSPACE|EXTERNALHELP)\\s+([a-z0-9-_]+))",
|
||||
"name": "comment.documentation.embedded.powershell"
|
||||
}
|
||||
]
|
||||
},
|
||||
"doubleQuotedStringEscapes": {
|
||||
"patterns": [
|
||||
{
|
||||
"match": "`[0abnfrvt\"'$`]",
|
||||
"name": "constant.character.escape.powershell"
|
||||
},
|
||||
{
|
||||
"match": "\"\"",
|
||||
"name": "constant.character.escape.powershell"
|
||||
}
|
||||
]
|
||||
},
|
||||
"interpolatedStringContent": {
|
||||
"begin": "\\(",
|
||||
"beginCaptures": {
|
||||
"0": {
|
||||
"name": "keyword.other.powershell"
|
||||
}
|
||||
},
|
||||
"contentName": "interpolated.simple.source.powershell",
|
||||
"end": "\\)",
|
||||
"endCaptures": {
|
||||
"0": {
|
||||
"name": "keyword.other.powershell"
|
||||
}
|
||||
},
|
||||
"patterns": [
|
||||
{
|
||||
"include": "$self"
|
||||
},
|
||||
{
|
||||
"include": "#interpolation"
|
||||
},
|
||||
{
|
||||
"include": "#interpolatedStringContent"
|
||||
}
|
||||
]
|
||||
},
|
||||
"interpolation": {
|
||||
"begin": "(\\$)\\(",
|
||||
"beginCaptures": {
|
||||
"0": {
|
||||
"name": "keyword.other.powershell"
|
||||
}
|
||||
},
|
||||
"contentName": "interpolated.complex.source.powershell",
|
||||
"end": "\\)",
|
||||
"endCaptures": {
|
||||
"0": {
|
||||
"name": "keyword.other.powershell"
|
||||
}
|
||||
},
|
||||
"patterns": [
|
||||
{
|
||||
"include": "$self"
|
||||
},
|
||||
{
|
||||
"include": "#interpolation"
|
||||
},
|
||||
{
|
||||
"include": "#interpolatedStringContent"
|
||||
}
|
||||
]
|
||||
},
|
||||
"numericConstant": {
|
||||
"patterns": [
|
||||
{
|
||||
"captures": {
|
||||
"1": {
|
||||
"name": "support.constant.powershell"
|
||||
},
|
||||
"2": {
|
||||
"name": "keyword.operator.math.powershell"
|
||||
},
|
||||
"3": {
|
||||
"name": "support.constant.powershell"
|
||||
},
|
||||
"4": {
|
||||
"name": "keyword.other.powershell"
|
||||
}
|
||||
},
|
||||
"match": "(?i:\\d+(E)(\\+|\\-)\\d+(d)?(mb|kb|gb)?)",
|
||||
"name": "constant.numeric.scientific.powershell"
|
||||
},
|
||||
{
|
||||
"captures": {
|
||||
"1": {
|
||||
"name": "support.constant.powershell"
|
||||
},
|
||||
"2": {
|
||||
"name": "keyword.other.powershell"
|
||||
}
|
||||
},
|
||||
"match": "(?i:(0x)[a-f0-9]+(mb|kb|gb)?)",
|
||||
"name": "constant.numeric.hexadecimal.powershell"
|
||||
},
|
||||
{
|
||||
"captures": {
|
||||
"1": {
|
||||
"name": "support.constant.powershell"
|
||||
},
|
||||
"2": {
|
||||
"name": "support.constant.powershell"
|
||||
},
|
||||
"3": {
|
||||
"name": "keyword.other.powershell"
|
||||
}
|
||||
},
|
||||
"match": "\\d*(?<!\\.)(\\.)\\d+(d)?(mb|kb|gb)?",
|
||||
"name": "constant.numeric.double.powershell"
|
||||
},
|
||||
{
|
||||
"captures": {
|
||||
"1": {
|
||||
"name": "support.constant.powershell"
|
||||
},
|
||||
"2": {
|
||||
"name": "keyword.other.powershell"
|
||||
}
|
||||
},
|
||||
"match": "(?<!\\w)\\d+(d)?(mb|kb|gb)?(?!\\w)",
|
||||
"name": "constant.numeric.powershell"
|
||||
}
|
||||
]
|
||||
},
|
||||
"scriptblock": {
|
||||
"begin": "\\{",
|
||||
"end": "\\}",
|
||||
"name": "meta.scriptblock.powershell",
|
||||
"patterns": [
|
||||
{
|
||||
"include": "$self"
|
||||
}
|
||||
]
|
||||
},
|
||||
"variable": {
|
||||
"patterns": [
|
||||
{
|
||||
"captures": {
|
||||
"1": {
|
||||
"name": "keyword.other.powershell"
|
||||
},
|
||||
"2": {
|
||||
"name": "constant.numeric.powershell"
|
||||
}
|
||||
},
|
||||
"comment": "Style var name as numeric constant so that they stand out.",
|
||||
"match": "(\\$)(?i:(\\$|\\?|\\^|args|ConfirmPreference|ConsoleFileName|DebugPreference|Error|ErrorActionPreference|ErrorView|ExecutionContext|false|FormatEnumerationLimit|HOME|Host|input|MaximumAliasCount|MaximumDriveCount|MaximumErrorCount|MaximumFunctionCount|MaximumHistoryCount|MaximumVariableCount|MyInvocation|NestedPromptLevel|null|OutputEncoding|PID|PROFILE|ProgressPreference|PSBoundParameters|PSCulture|PSEmailServer|PSHOME|PSSessionApplicationName|PSSessionConfigurationName|PSSessionOption|PSUICulture|PSVersionTable|PWD|ReportErrorShowExceptionClass|ReportErrorShowInnerException|ReportErrorShowSource|ReportErrorShowStackTrace|ShellId|StackTrace|true|VerbosePreference|WarningPreference|WhatIfPreference))\\b",
|
||||
"name": "support.variable.builtin.powershell"
|
||||
},
|
||||
{
|
||||
"captures": {
|
||||
"1": {
|
||||
"name": "keyword.other.variable.powershell"
|
||||
},
|
||||
"2": {
|
||||
"name": "storage.modifier.scope.powershell"
|
||||
},
|
||||
"3": {
|
||||
"name": "variable.other.readwrite.powershell"
|
||||
}
|
||||
},
|
||||
"match": "(?i:(\\$)(?:(private|script|global):)?([a-z0-9_]+))"
|
||||
},
|
||||
{
|
||||
"captures": {
|
||||
"1": {
|
||||
"name": "keyword.other.variable.powershell"
|
||||
},
|
||||
"2": {
|
||||
"name": "variable.other.readwrite.powershell"
|
||||
},
|
||||
"3": {
|
||||
"name": "storage.modifier.scope.powershell"
|
||||
}
|
||||
},
|
||||
"match": "(?i:(\\$)(\\{(?:(private|script|global):)?.+?\\}))"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"scopeName": "source.powershell",
|
||||
"uuid": "f8f5ffb0-503e-11df-9879-0800200c9a66"
|
||||
}
|
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"word_wrap": false,
|
||||
"translate_tabs_to_spaces": true
|
||||
}
|
615
Sublime/PowerShell/Support/PowershellSyntax.tmLanguage
Normal file
615
Sublime/PowerShell/Support/PowershellSyntax.tmLanguage
Normal file
@@ -0,0 +1,615 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>fileTypes</key>
|
||||
<array>
|
||||
<string>ps1</string>
|
||||
<string>psm1</string>
|
||||
<string>psd1</string>
|
||||
</array>
|
||||
<key>name</key>
|
||||
<string>Powershell v2</string>
|
||||
<key>patterns</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>begin</key>
|
||||
<string><#</string>
|
||||
<key>beginCaptures</key>
|
||||
<dict>
|
||||
<key>0</key>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>punctuation.start.definition.comment.block.powershell</string>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>end</key>
|
||||
<string>#></string>
|
||||
<key>endCaptures</key>
|
||||
<dict>
|
||||
<key>0</key>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>punctuation.end.definition.comment.block.powershell</string>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>name</key>
|
||||
<string>comment.block.powershell</string>
|
||||
<key>patterns</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>include</key>
|
||||
<string>#commentEmbeddedDocs</string>
|
||||
</dict>
|
||||
</array>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>begin</key>
|
||||
<string>(?<![\\-])#</string>
|
||||
<key>end</key>
|
||||
<string>$</string>
|
||||
<key>name</key>
|
||||
<string>comment.line.powershell</string>
|
||||
<key>patterns</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>include</key>
|
||||
<string>#commentEmbeddedDocs</string>
|
||||
</dict>
|
||||
</array>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>include</key>
|
||||
<string>#variable</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>include</key>
|
||||
<string>#scriptblock</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>begin</key>
|
||||
<string>(?<!(?<!`)")"</string>
|
||||
<key>end</key>
|
||||
<string>"(?!")</string>
|
||||
<key>name</key>
|
||||
<string>string.quoted.double.powershell</string>
|
||||
<key>patterns</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>include</key>
|
||||
<string>#variable</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>include</key>
|
||||
<string>#doubleQuotedStringEscapes</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>include</key>
|
||||
<string>#interpolation</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>match</key>
|
||||
<string>`\s*$</string>
|
||||
<key>name</key>
|
||||
<string>keyword.other.powershell</string>
|
||||
</dict>
|
||||
</array>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>comment</key>
|
||||
<string>Needed to parse stuff correctly in 'argument mode'. (See about_parsing.)</string>
|
||||
<key>include</key>
|
||||
<string>#doubleQuotedStringEscapes</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>begin</key>
|
||||
<string>(?<!')'</string>
|
||||
<key>end</key>
|
||||
<string>'(?!')</string>
|
||||
<key>name</key>
|
||||
<string>string.quoted.single.powershell</string>
|
||||
<key>patterns</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>match</key>
|
||||
<string>''</string>
|
||||
<key>name</key>
|
||||
<string>constant.character.escape.powershell</string>
|
||||
</dict>
|
||||
</array>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>begin</key>
|
||||
<string>@"$</string>
|
||||
<key>end</key>
|
||||
<string>^"@</string>
|
||||
<key>name</key>
|
||||
<string>string.quoted.double.heredoc.powershell</string>
|
||||
<key>patterns</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>include</key>
|
||||
<string>#interpolation</string>
|
||||
</dict>
|
||||
</array>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>begin</key>
|
||||
<string>@\(</string>
|
||||
<key>captures</key>
|
||||
<dict>
|
||||
<key>0</key>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>keyword.other.powershell</string>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>end</key>
|
||||
<string>\)</string>
|
||||
<key>name</key>
|
||||
<string>meta.group.array-expression.powershell</string>
|
||||
<key>patterns</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>include</key>
|
||||
<string>$self</string>
|
||||
</dict>
|
||||
</array>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>begin</key>
|
||||
<string>\$\(</string>
|
||||
<key>captures</key>
|
||||
<dict>
|
||||
<key>0</key>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>keyword.other.powershell</string>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>comment</key>
|
||||
<string>TODO: move to repo; make recursive.</string>
|
||||
<key>end</key>
|
||||
<string>\)</string>
|
||||
<key>name</key>
|
||||
<string>meta.group.complex.subexpression.powershell</string>
|
||||
<key>patterns</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>include</key>
|
||||
<string>$self</string>
|
||||
</dict>
|
||||
</array>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>begin</key>
|
||||
<string>@'$</string>
|
||||
<key>end</key>
|
||||
<string>^'@$</string>
|
||||
<key>name</key>
|
||||
<string>string.quoted.double.heredoc.powershell</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>include</key>
|
||||
<string>#numericConstant</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>match</key>
|
||||
<string>-([lg][te]|[ci]?(eq|ne))</string>
|
||||
<key>name</key>
|
||||
<string>keyword.operator.logical.powershell</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>include</key>
|
||||
<string>#PSDefaults</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>match</key>
|
||||
<string>(?i:[a-z][a-z0-9]+-[a-z][a-z0-9]+)</string>
|
||||
<key>name</key>
|
||||
<string>support.function.powershell</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>match</key>
|
||||
<string>\b(?i:if|else|elseif|switch|while|default|try|finally|catch|for|do|until|break|continue|foreach|return|filter|in|trap|throw|param|begin|process|end|function|global|local|private|script|contained)\b</string>
|
||||
<key>name</key>
|
||||
<string>keyword.control.powershell</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>match</key>
|
||||
<string>-(?i:(?:[ic]?eq|ne|[gl][te]|(?:not)?(?:like|match|contains)|replace)|is(?:not)?|as|and|or|band|bor|not|f)\b</string>
|
||||
<key>name</key>
|
||||
<string>keyword.operator.comparison.powershell</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>match</key>
|
||||
<string>-(?i:and|or|not)|!</string>
|
||||
<key>name</key>
|
||||
<string>keyword.operator.logical.powershell</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>match</key>
|
||||
<string>-(?i:f|band|bor|-bnot)\b</string>
|
||||
<key>name</key>
|
||||
<string>keyword.operator.bitwise.powershell</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>match</key>
|
||||
<string>-f\b</string>
|
||||
<key>name</key>
|
||||
<string>keyword.operator.string-format.powershell</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>match</key>
|
||||
<string>[+%*/-]?=|[+/*%-]</string>
|
||||
<key>name</key>
|
||||
<string>keyword.operator.assignment.powershell</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>match</key>
|
||||
<string>2>&1|>>|>|<<|<|>|>\||2>|2>>|1>></string>
|
||||
<key>name</key>
|
||||
<string>keyword.operator.redirection.powershell</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>match</key>
|
||||
<string>\|{2}|&{2}|;</string>
|
||||
<key>name</key>
|
||||
<string>keyword.other.statement-separator.powershell</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>match</key>
|
||||
<string>&|(?<!\w)\.(?= )|`|,|\|</string>
|
||||
<key>name</key>
|
||||
<string>keyword.operator.other.powershell</string>
|
||||
</dict>
|
||||
</array>
|
||||
<key>repository</key>
|
||||
<dict>
|
||||
<key>PSDefaults</key>
|
||||
<dict>
|
||||
<key>comment</key>
|
||||
<string>Default commandlets in Powershell v2</string>
|
||||
<key>match</key>
|
||||
<string>Disconnect-(WSMan)|Exit-(PSSession)|Copy-(Item|ItemProperty)|Resolve-(Path)|Group-(Object)|Remove-(Computer|Event|EventLog|Item|ItemProperty|Job|Module|PSBreakpoint|PSDrive|PSSession|PSSnapin|Variable|WmiObject|WSManInstance)|Unregister-(Event|PSSessionConfiguration)|Tee-(Object)|Pop-(Location)|Set-(Acl|Alias|AuthenticodeSignature|Content|Date|ExecutionPolicy|Item|ItemProperty|Location|PSBreakpoint|PSDebug|PSSessionConfiguration|Service|StrictMode|TraceSource|Variable|WmiInstance|WSManInstance|WSManQuickConfig)|Format-(Custom|List|Table|Wide)|Invoke-(Command|Expression|History|Item|WmiMethod|WSManAction)|Export-(Alias|Clixml|Console|Counter|Csv|FormatData|ModuleMember|PSSession)|Update-(FormatData|List|TypeData)|Sort-(Object)|Measure-(Command|Object)|ForEach-(Object)|Connect-(WSMan)|Suspend-(Service)|ConvertFrom-(Csv|SecureString|StringData)|Where-(Object)|Rename-(Item|ItemProperty)|Convert-(Path)|Select-(Object|String|Xml)|Import-(Alias|Clixml|Counter|Csv|LocalizedData|Module|PSSession)|Stop-(Computer|Job|Process|Service|Transcript)|New-(Alias|Event|EventLog|Item|ItemProperty|Module|ModuleManifest|Object|PSDrive|PSSession|PSSessionOption|Service|TimeSpan|Variable|WebServiceProxy|WSManInstance|WSManSessionOption)|Resume-(Service)|Show-(EventLog)|Out-(Default|File|GridView|Host|Null|Printer|String)|Undo-(Transaction)|Trace-(Command)|Clear-(Content|EventLog|History|Item|ItemProperty|Variable)|Push-(Location)|Split-(Path)|Disable-(ComputerRestore|PSBreakpoint|PSSessionConfiguration|WSManCredSSP)|Reset-(ComputerMachinePassword)|Restore-(Computer)|ConvertTo-(Csv|Html|SecureString|Xml)|Enable-(ComputerRestore|PSBreakpoint|PSRemoting|PSSessionConfiguration|WSManCredSSP)|Join-(Path)|Register-(EngineEvent|ObjectEvent|PSSessionConfiguration|WmiEvent)|Compare-(Object)|Get-(Acl|Alias|AuthenticodeSignature|ChildItem|Command|ComputerRestorePoint|Content|Counter|Credential|Culture|Date|Event|EventLog|EventSubscriber|ExecutionPolicy|FormatData|Help|History|Host|HotFix|Item|ItemProperty|Job|Location|Member|Module|PfxCertificate|Process|PSBreakpoint|PSCallStack|PSDrive|PSProvider|PSSession|PSSessionConfiguration|PSSnapin|Random|Service|TraceSource|Transaction|UICulture|Unique|Variable|WinEvent|WmiObject|WSManCredSSP|WSManInstance)|Receive-(Job)|Move-(Item|ItemProperty)|Add-(Computer|Content|History|Member|PSSnapin|Type)|Wait-(Event|Job|Process)|Send-(MailMessage)|Read-(Host)|Complete-(Transaction)|Checkpoint-(Computer)|Debug-(Process)|Use-(Transaction)|Restart-(Computer|Service)|Write-(Debug|Error|EventLog|Host|Output|Progress|Verbose|Warning)|Test-(ComputerSecureChannel|Connection|ModuleManifest|Path|WSMan)|Start-(Job|Process|Service|Sleep|Transaction|Transcript)|Limit-(EventLog)|Enter-(PSSession)</string>
|
||||
<key>name</key>
|
||||
<string>support.function.builtin.powershell</string>
|
||||
</dict>
|
||||
<key>commentEmbeddedDocs</key>
|
||||
<dict>
|
||||
<key>patterns</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>captures</key>
|
||||
<dict>
|
||||
<key>1</key>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>constant.string.documentation.powershell</string>
|
||||
</dict>
|
||||
<key>2</key>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>keyword.operator.documentation.powershell</string>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>match</key>
|
||||
<string>(?i:\s*(\.)(SYNOPSIS|DESCRIPTION|EXAMPLE|INPUTS|OUTPUTS|NOTES|LINK|COMPONENT|FUNCTIONALITY))</string>
|
||||
<key>name</key>
|
||||
<string>comment.documentation.embedded.powershell</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>captures</key>
|
||||
<dict>
|
||||
<key>1</key>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>constant.string.documentation.powershell</string>
|
||||
</dict>
|
||||
<key>2</key>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>keyword.operator.documentation.powershell</string>
|
||||
</dict>
|
||||
<key>3</key>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>keyword.operator.documentation.powershell</string>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>match</key>
|
||||
<string>(?i:\s*(\.)(PARAMETER|FORWARDHELPTARGETNAME|FORWARDHELPCATEGORY|REMOTEHELPRUNSPACE|EXTERNALHELP)\s+([a-z0-9-_]+))</string>
|
||||
<key>name</key>
|
||||
<string>comment.documentation.embedded.powershell</string>
|
||||
</dict>
|
||||
</array>
|
||||
</dict>
|
||||
<key>doubleQuotedStringEscapes</key>
|
||||
<dict>
|
||||
<key>patterns</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>match</key>
|
||||
<string>`[0abnfrvt"'$`]</string>
|
||||
<key>name</key>
|
||||
<string>constant.character.escape.powershell</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>match</key>
|
||||
<string>""</string>
|
||||
<key>name</key>
|
||||
<string>constant.character.escape.powershell</string>
|
||||
</dict>
|
||||
</array>
|
||||
</dict>
|
||||
<key>interpolatedStringContent</key>
|
||||
<dict>
|
||||
<key>begin</key>
|
||||
<string>\(</string>
|
||||
<key>beginCaptures</key>
|
||||
<dict>
|
||||
<key>0</key>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>keyword.other.powershell</string>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>contentName</key>
|
||||
<string>interpolated.simple.source.powershell</string>
|
||||
<key>end</key>
|
||||
<string>\)</string>
|
||||
<key>endCaptures</key>
|
||||
<dict>
|
||||
<key>0</key>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>keyword.other.powershell</string>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>patterns</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>include</key>
|
||||
<string>$self</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>include</key>
|
||||
<string>#interpolation</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>include</key>
|
||||
<string>#interpolatedStringContent</string>
|
||||
</dict>
|
||||
</array>
|
||||
</dict>
|
||||
<key>interpolation</key>
|
||||
<dict>
|
||||
<key>begin</key>
|
||||
<string>(\$)\(</string>
|
||||
<key>beginCaptures</key>
|
||||
<dict>
|
||||
<key>0</key>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>keyword.other.powershell</string>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>contentName</key>
|
||||
<string>interpolated.complex.source.powershell</string>
|
||||
<key>end</key>
|
||||
<string>\)</string>
|
||||
<key>endCaptures</key>
|
||||
<dict>
|
||||
<key>0</key>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>keyword.other.powershell</string>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>patterns</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>include</key>
|
||||
<string>$self</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>include</key>
|
||||
<string>#interpolation</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>include</key>
|
||||
<string>#interpolatedStringContent</string>
|
||||
</dict>
|
||||
</array>
|
||||
</dict>
|
||||
<key>numericConstant</key>
|
||||
<dict>
|
||||
<key>patterns</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>captures</key>
|
||||
<dict>
|
||||
<key>1</key>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>support.constant.powershell</string>
|
||||
</dict>
|
||||
<key>2</key>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>keyword.operator.math.powershell</string>
|
||||
</dict>
|
||||
<key>3</key>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>support.constant.powershell</string>
|
||||
</dict>
|
||||
<key>4</key>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>keyword.other.powershell</string>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>match</key>
|
||||
<string>(?i:\d+(E)(\+|\-)\d+(d)?(mb|kb|gb)?)</string>
|
||||
<key>name</key>
|
||||
<string>constant.numeric.scientific.powershell</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>captures</key>
|
||||
<dict>
|
||||
<key>1</key>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>support.constant.powershell</string>
|
||||
</dict>
|
||||
<key>2</key>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>keyword.other.powershell</string>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>match</key>
|
||||
<string>(?i:(0x)[a-f0-9]+(mb|kb|gb)?)</string>
|
||||
<key>name</key>
|
||||
<string>constant.numeric.hexadecimal.powershell</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>captures</key>
|
||||
<dict>
|
||||
<key>1</key>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>support.constant.powershell</string>
|
||||
</dict>
|
||||
<key>2</key>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>support.constant.powershell</string>
|
||||
</dict>
|
||||
<key>3</key>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>keyword.other.powershell</string>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>match</key>
|
||||
<string>\d*(?<!\.)(\.)\d+(d)?(mb|kb|gb)?</string>
|
||||
<key>name</key>
|
||||
<string>constant.numeric.double.powershell</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>captures</key>
|
||||
<dict>
|
||||
<key>1</key>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>support.constant.powershell</string>
|
||||
</dict>
|
||||
<key>2</key>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>keyword.other.powershell</string>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>match</key>
|
||||
<string>(?<!\w)\d+(d)?(mb|kb|gb)?(?!\w)</string>
|
||||
<key>name</key>
|
||||
<string>constant.numeric.powershell</string>
|
||||
</dict>
|
||||
</array>
|
||||
</dict>
|
||||
<key>scriptblock</key>
|
||||
<dict>
|
||||
<key>begin</key>
|
||||
<string>\{</string>
|
||||
<key>end</key>
|
||||
<string>\}</string>
|
||||
<key>name</key>
|
||||
<string>meta.scriptblock.powershell</string>
|
||||
<key>patterns</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>include</key>
|
||||
<string>$self</string>
|
||||
</dict>
|
||||
</array>
|
||||
</dict>
|
||||
<key>variable</key>
|
||||
<dict>
|
||||
<key>patterns</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>captures</key>
|
||||
<dict>
|
||||
<key>1</key>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>keyword.other.powershell</string>
|
||||
</dict>
|
||||
<key>2</key>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>constant.numeric.powershell</string>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>comment</key>
|
||||
<string>Style var name as numeric constant so that they stand out.</string>
|
||||
<key>match</key>
|
||||
<string>(\$)(?i:(\$|\?|\^|args|ConfirmPreference|ConsoleFileName|DebugPreference|Error|ErrorActionPreference|ErrorView|ExecutionContext|false|FormatEnumerationLimit|HOME|Host|input|MaximumAliasCount|MaximumDriveCount|MaximumErrorCount|MaximumFunctionCount|MaximumHistoryCount|MaximumVariableCount|MyInvocation|NestedPromptLevel|null|OutputEncoding|PID|PROFILE|ProgressPreference|PSBoundParameters|PSCulture|PSEmailServer|PSHOME|PSSessionApplicationName|PSSessionConfigurationName|PSSessionOption|PSUICulture|PSVersionTable|PWD|ReportErrorShowExceptionClass|ReportErrorShowInnerException|ReportErrorShowSource|ReportErrorShowStackTrace|ShellId|StackTrace|true|VerbosePreference|WarningPreference|WhatIfPreference))\b</string>
|
||||
<key>name</key>
|
||||
<string>support.variable.builtin.powershell</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>captures</key>
|
||||
<dict>
|
||||
<key>1</key>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>keyword.other.variable.powershell</string>
|
||||
</dict>
|
||||
<key>2</key>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>storage.modifier.scope.powershell</string>
|
||||
</dict>
|
||||
<key>3</key>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>variable.other.readwrite.powershell</string>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>match</key>
|
||||
<string>(?i:(\$)(?:(private|script|global):)?([a-z0-9_]+))</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>captures</key>
|
||||
<dict>
|
||||
<key>1</key>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>keyword.other.variable.powershell</string>
|
||||
</dict>
|
||||
<key>2</key>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>variable.other.readwrite.powershell</string>
|
||||
</dict>
|
||||
<key>3</key>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>storage.modifier.scope.powershell</string>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>match</key>
|
||||
<string>(?i:(\$)(\{(?:(private|script|global):)?.+?\}))</string>
|
||||
</dict>
|
||||
</array>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>scopeName</key>
|
||||
<string>source.powershell</string>
|
||||
<key>uuid</key>
|
||||
<string>f8f5ffb0-503e-11df-9879-0800200c9a66</string>
|
||||
</dict>
|
||||
</plist>
|
7
Sublime/PowerShell/manifest.in
Normal file
7
Sublime/PowerShell/manifest.in
Normal file
@@ -0,0 +1,7 @@
|
||||
include *.sublime-*
|
||||
include *.tmLanguage
|
||||
include *.tmPreferences
|
||||
include LICENSE.txt
|
||||
|
||||
exclude *.sublime-project
|
||||
exclude *.sublime-workspace
|
1
Sublime/PowerShell/package-metadata.json
Normal file
1
Sublime/PowerShell/package-metadata.json
Normal file
@@ -0,0 +1 @@
|
||||
{"url": "https://github.com/SublimeText/PowerShell", "version": "2013.01.25.16.56.44", "description": "Support for the MS PowerShell 2 programming language."}
|
591
Sublime/PowerShell/setup.py
Normal file
591
Sublime/PowerShell/setup.py
Normal file
@@ -0,0 +1,591 @@
|
||||
# encoding: utf-8
|
||||
|
||||
PACKAGE_VERSION = "11.12.2011"
|
||||
|
||||
"""Commands to build and manage .sublime-package archives with distutils."""
|
||||
|
||||
import sys
|
||||
import os, string
|
||||
from types import *
|
||||
from glob import glob
|
||||
from distutils import log, dir_util, dep_util, file_util, archive_util
|
||||
from distutils.core import Command
|
||||
from distutils.core import setup
|
||||
from distutils.text_file import TextFile
|
||||
from distutils.filelist import FileList
|
||||
from distutils.errors import *
|
||||
from distutils.spawn import spawn
|
||||
from distutils.dir_util import mkpath
|
||||
import subprocess
|
||||
|
||||
|
||||
def make_zipfile (base_name, base_dir, verbose=0, dry_run=0):
|
||||
"""Create a zip file from all the files under 'base_dir'. The output
|
||||
zip file will be named 'base_dir' + ".zip". Uses either the "zipfile"
|
||||
Python module (if available) or the InfoZIP "zip" utility (if installed
|
||||
and found on the default search path). If neither tool is available,
|
||||
raises DistutilsExecError. Returns the name of the output zip file.
|
||||
"""
|
||||
try:
|
||||
import zipfile
|
||||
except ImportError:
|
||||
zipfile = None
|
||||
|
||||
zip_filename = base_name + ".sublime-package"
|
||||
mkpath(os.path.dirname(zip_filename), dry_run=dry_run)
|
||||
|
||||
# If zipfile module is not available, try spawning an external
|
||||
# 'zip' command.
|
||||
if zipfile is None:
|
||||
if verbose:
|
||||
zipoptions = "-r"
|
||||
else:
|
||||
zipoptions = "-rq"
|
||||
|
||||
try:
|
||||
spawn(["zip", zipoptions, zip_filename, base_dir],
|
||||
dry_run=dry_run)
|
||||
except DistutilsExecError:
|
||||
# XXX really should distinguish between "couldn't find
|
||||
# external 'zip' command" and "zip failed".
|
||||
raise DistutilsExecError, \
|
||||
("unable to create zip file '%s': "
|
||||
"could neither import the 'zipfile' module nor "
|
||||
"find a standalone zip utility") % zip_filename
|
||||
|
||||
else:
|
||||
log.info("creating '%s' and adding '%s' to it",
|
||||
zip_filename, base_dir)
|
||||
|
||||
if not dry_run:
|
||||
z = zipfile.ZipFile(zip_filename, "w",
|
||||
compression=zipfile.ZIP_DEFLATED)
|
||||
|
||||
for dirpath, dirnames, filenames in os.walk(base_dir):
|
||||
for name in filenames:
|
||||
path = os.path.normpath(os.path.join(dirpath, name))
|
||||
arcname = path[len(base_dir):]
|
||||
# if dirpath == base_dir:
|
||||
# arcname = name
|
||||
# else:
|
||||
# arcname = path[len(base_dir):]
|
||||
# print arcname
|
||||
if os.path.isfile(path):
|
||||
z.write(path, arcname)
|
||||
log.info("adding '%s'" % path)
|
||||
z.close()
|
||||
|
||||
return zip_filename
|
||||
|
||||
|
||||
def show_formats ():
|
||||
"""Print all possible values for the 'formats' option (used by
|
||||
the "--help-formats" command-line option).
|
||||
"""
|
||||
from distutils.fancy_getopt import FancyGetopt
|
||||
from distutils.archive_util import ARCHIVE_FORMATS
|
||||
formats=[]
|
||||
for format in ARCHIVE_FORMATS.keys():
|
||||
formats.append(("formats=" + format, None,
|
||||
ARCHIVE_FORMATS[format][2]))
|
||||
formats.sort()
|
||||
pretty_printer = FancyGetopt(formats)
|
||||
pretty_printer.print_help(
|
||||
"List of available source distribution formats:")
|
||||
|
||||
class spa (Command):
|
||||
|
||||
description = "create a source distribution (tarball, zip file, etc.)"
|
||||
|
||||
user_options = [
|
||||
('template=', 't',
|
||||
"name of manifest template file [default: MANIFEST.in]"),
|
||||
('manifest=', 'm',
|
||||
"name of manifest file [default: MANIFEST]"),
|
||||
('use-defaults', None,
|
||||
"include the default file set in the manifest "
|
||||
"[default; disable with --no-defaults]"),
|
||||
('no-defaults', None,
|
||||
"don't include the default file set"),
|
||||
('prune', None,
|
||||
"specifically exclude files/directories that should not be "
|
||||
"distributed (build tree, RCS/CVS dirs, etc.) "
|
||||
"[default; disable with --no-prune]"),
|
||||
('no-prune', None,
|
||||
"don't automatically exclude anything"),
|
||||
('manifest-only', 'o',
|
||||
"just regenerate the manifest and then stop "
|
||||
"(implies --force-manifest)"),
|
||||
('force-manifest', 'f',
|
||||
"forcibly regenerate the manifest and carry on as usual"),
|
||||
('formats=', None,
|
||||
"formats for source distribution (comma-separated list)"),
|
||||
('keep-temp', 'k',
|
||||
"keep the distribution tree around after creating " +
|
||||
"archive file(s)"),
|
||||
('dist-dir=', 'd',
|
||||
"directory to put the source distribution archive(s) in "
|
||||
"[default: dist]"),
|
||||
]
|
||||
|
||||
boolean_options = ['use-defaults', 'prune',
|
||||
'manifest-only', 'force-manifest',
|
||||
'keep-temp']
|
||||
|
||||
help_options = [
|
||||
('help-formats', None,
|
||||
"list available distribution formats", show_formats),
|
||||
]
|
||||
|
||||
negative_opt = {'no-defaults': 'use-defaults',
|
||||
'no-prune': 'prune' }
|
||||
|
||||
default_format = { 'posix': 'gztar',
|
||||
'nt': 'zip' }
|
||||
|
||||
def initialize_options (self):
|
||||
# 'template' and 'manifest' are, respectively, the names of
|
||||
# the manifest template and manifest file.
|
||||
self.template = None
|
||||
self.manifest = None
|
||||
|
||||
# 'use_defaults': if true, we will include the default file set
|
||||
# in the manifest
|
||||
self.use_defaults = 1
|
||||
self.prune = 1
|
||||
|
||||
self.manifest_only = 0
|
||||
self.force_manifest = 0
|
||||
|
||||
self.formats = None
|
||||
self.keep_temp = 0
|
||||
self.dist_dir = None
|
||||
|
||||
self.archive_files = None
|
||||
|
||||
|
||||
def finalize_options (self):
|
||||
if self.manifest is None:
|
||||
self.manifest = "MANIFEST"
|
||||
if self.template is None:
|
||||
self.template = "MANIFEST.in"
|
||||
|
||||
self.ensure_string_list('formats')
|
||||
if self.formats is None:
|
||||
try:
|
||||
self.formats = [self.default_format[os.name]]
|
||||
except KeyError:
|
||||
raise DistutilsPlatformError, \
|
||||
"don't know how to create source distributions " + \
|
||||
"on platform %s" % os.name
|
||||
|
||||
bad_format = archive_util.check_archive_formats(self.formats)
|
||||
if bad_format:
|
||||
raise DistutilsOptionError, \
|
||||
"unknown archive format '%s'" % bad_format
|
||||
|
||||
if self.dist_dir is None:
|
||||
self.dist_dir = "dist"
|
||||
|
||||
|
||||
def run (self):
|
||||
|
||||
# 'filelist' contains the list of files that will make up the
|
||||
# manifest
|
||||
self.filelist = FileList()
|
||||
|
||||
# Ensure that all required meta-data is given; warn if not (but
|
||||
# don't die, it's not *that* serious!)
|
||||
self.check_metadata()
|
||||
|
||||
# Do whatever it takes to get the list of files to process
|
||||
# (process the manifest template, read an existing manifest,
|
||||
# whatever). File list is accumulated in 'self.filelist'.
|
||||
self.get_file_list()
|
||||
|
||||
# If user just wanted us to regenerate the manifest, stop now.
|
||||
if self.manifest_only:
|
||||
return
|
||||
|
||||
# Otherwise, go ahead and create the source distribution tarball,
|
||||
# or zipfile, or whatever.
|
||||
self.make_distribution()
|
||||
|
||||
|
||||
def check_metadata (self):
|
||||
"""Ensure that all required elements of meta-data (name, version,
|
||||
URL, (author and author_email) or (maintainer and
|
||||
maintainer_email)) are supplied by the Distribution object; warn if
|
||||
any are missing.
|
||||
"""
|
||||
metadata = self.distribution.metadata
|
||||
|
||||
missing = []
|
||||
for attr in ('name', 'version', 'url'):
|
||||
if not (hasattr(metadata, attr) and getattr(metadata, attr)):
|
||||
missing.append(attr)
|
||||
|
||||
if missing:
|
||||
self.warn("missing required meta-data: " +
|
||||
string.join(missing, ", "))
|
||||
|
||||
if metadata.author:
|
||||
if not metadata.author_email:
|
||||
self.warn("missing meta-data: if 'author' supplied, " +
|
||||
"'author_email' must be supplied too")
|
||||
elif metadata.maintainer:
|
||||
if not metadata.maintainer_email:
|
||||
self.warn("missing meta-data: if 'maintainer' supplied, " +
|
||||
"'maintainer_email' must be supplied too")
|
||||
else:
|
||||
self.warn("missing meta-data: either (author and author_email) " +
|
||||
"or (maintainer and maintainer_email) " +
|
||||
"must be supplied")
|
||||
|
||||
# check_metadata ()
|
||||
|
||||
|
||||
def get_file_list (self):
|
||||
"""Figure out the list of files to include in the source
|
||||
distribution, and put it in 'self.filelist'. This might involve
|
||||
reading the manifest template (and writing the manifest), or just
|
||||
reading the manifest, or just using the default file set -- it all
|
||||
depends on the user's options and the state of the filesystem.
|
||||
"""
|
||||
|
||||
# If we have a manifest template, see if it's newer than the
|
||||
# manifest; if so, we'll regenerate the manifest.
|
||||
template_exists = os.path.isfile(self.template)
|
||||
if template_exists:
|
||||
template_newer = dep_util.newer(self.template, self.manifest)
|
||||
|
||||
# The contents of the manifest file almost certainly depend on the
|
||||
# setup script as well as the manifest template -- so if the setup
|
||||
# script is newer than the manifest, we'll regenerate the manifest
|
||||
# from the template. (Well, not quite: if we already have a
|
||||
# manifest, but there's no template -- which will happen if the
|
||||
# developer elects to generate a manifest some other way -- then we
|
||||
# can't regenerate the manifest, so we don't.)
|
||||
self.debug_print("checking if %s newer than %s" %
|
||||
(self.distribution.script_name, self.manifest))
|
||||
setup_newer = dep_util.newer(self.distribution.script_name,
|
||||
self.manifest)
|
||||
|
||||
# cases:
|
||||
# 1) no manifest, template exists: generate manifest
|
||||
# (covered by 2a: no manifest == template newer)
|
||||
# 2) manifest & template exist:
|
||||
# 2a) template or setup script newer than manifest:
|
||||
# regenerate manifest
|
||||
# 2b) manifest newer than both:
|
||||
# do nothing (unless --force or --manifest-only)
|
||||
# 3) manifest exists, no template:
|
||||
# do nothing (unless --force or --manifest-only)
|
||||
# 4) no manifest, no template: generate w/ warning ("defaults only")
|
||||
|
||||
manifest_outofdate = (template_exists and
|
||||
(template_newer or setup_newer))
|
||||
force_regen = self.force_manifest or self.manifest_only
|
||||
manifest_exists = os.path.isfile(self.manifest)
|
||||
neither_exists = (not template_exists and not manifest_exists)
|
||||
|
||||
# Regenerate the manifest if necessary (or if explicitly told to)
|
||||
if manifest_outofdate or neither_exists or force_regen:
|
||||
if not template_exists:
|
||||
self.warn(("manifest template '%s' does not exist " +
|
||||
"(using default file list)") %
|
||||
self.template)
|
||||
self.filelist.findall()
|
||||
|
||||
if self.use_defaults:
|
||||
self.add_defaults()
|
||||
if template_exists:
|
||||
self.read_template()
|
||||
if self.prune:
|
||||
self.prune_file_list()
|
||||
|
||||
self.filelist.sort()
|
||||
self.filelist.remove_duplicates()
|
||||
self.write_manifest()
|
||||
|
||||
# Don't regenerate the manifest, just read it in.
|
||||
else:
|
||||
self.read_manifest()
|
||||
|
||||
# get_file_list ()
|
||||
|
||||
|
||||
def add_defaults (self):
|
||||
"""Add all the default files to self.filelist:
|
||||
- README or README.txt
|
||||
- setup.py
|
||||
- test/test*.py
|
||||
- all pure Python modules mentioned in setup script
|
||||
- all C sources listed as part of extensions or C libraries
|
||||
in the setup script (doesn't catch C headers!)
|
||||
Warns if (README or README.txt) or setup.py are missing; everything
|
||||
else is optional.
|
||||
"""
|
||||
|
||||
standards = [('README', 'README.txt'), self.distribution.script_name]
|
||||
for fn in standards:
|
||||
# XXX
|
||||
if fn == 'setup.py': continue # We don't want setup.py
|
||||
if type(fn) is TupleType:
|
||||
alts = fn
|
||||
got_it = 0
|
||||
for fn in alts:
|
||||
if os.path.exists(fn):
|
||||
got_it = 1
|
||||
self.filelist.append(fn)
|
||||
break
|
||||
|
||||
if not got_it:
|
||||
self.warn("standard file not found: should have one of " +
|
||||
string.join(alts, ', '))
|
||||
else:
|
||||
if os.path.exists(fn):
|
||||
self.filelist.append(fn)
|
||||
else:
|
||||
self.warn("standard file '%s' not found" % fn)
|
||||
|
||||
optional = ['test/test*.py', 'setup.cfg']
|
||||
for pattern in optional:
|
||||
files = filter(os.path.isfile, glob(pattern))
|
||||
if files:
|
||||
self.filelist.extend(files)
|
||||
|
||||
if self.distribution.has_pure_modules():
|
||||
build_py = self.get_finalized_command('build_py')
|
||||
self.filelist.extend(build_py.get_source_files())
|
||||
|
||||
if self.distribution.has_ext_modules():
|
||||
build_ext = self.get_finalized_command('build_ext')
|
||||
self.filelist.extend(build_ext.get_source_files())
|
||||
|
||||
if self.distribution.has_c_libraries():
|
||||
build_clib = self.get_finalized_command('build_clib')
|
||||
self.filelist.extend(build_clib.get_source_files())
|
||||
|
||||
if self.distribution.has_scripts():
|
||||
build_scripts = self.get_finalized_command('build_scripts')
|
||||
self.filelist.extend(build_scripts.get_source_files())
|
||||
|
||||
# add_defaults ()
|
||||
|
||||
|
||||
def read_template (self):
|
||||
"""Read and parse manifest template file named by self.template.
|
||||
|
||||
(usually "MANIFEST.in") The parsing and processing is done by
|
||||
'self.filelist', which updates itself accordingly.
|
||||
"""
|
||||
log.info("reading manifest template '%s'", self.template)
|
||||
template = TextFile(self.template,
|
||||
strip_comments=1,
|
||||
skip_blanks=1,
|
||||
join_lines=1,
|
||||
lstrip_ws=1,
|
||||
rstrip_ws=1,
|
||||
collapse_join=1)
|
||||
|
||||
while 1:
|
||||
line = template.readline()
|
||||
if line is None: # end of file
|
||||
break
|
||||
|
||||
try:
|
||||
self.filelist.process_template_line(line)
|
||||
except DistutilsTemplateError, msg:
|
||||
self.warn("%s, line %d: %s" % (template.filename,
|
||||
template.current_line,
|
||||
msg))
|
||||
|
||||
# read_template ()
|
||||
|
||||
|
||||
def prune_file_list (self):
|
||||
"""Prune off branches that might slip into the file list as created
|
||||
by 'read_template()', but really don't belong there:
|
||||
* the build tree (typically "build")
|
||||
* the release tree itself (only an issue if we ran "spa"
|
||||
previously with --keep-temp, or it aborted)
|
||||
* any RCS, CVS, .svn, .hg, .git, .bzr, _darcs directories
|
||||
"""
|
||||
build = self.get_finalized_command('build')
|
||||
base_dir = self.distribution.get_fullname()
|
||||
base_dir = self.distribution.get_name()
|
||||
|
||||
self.filelist.exclude_pattern(None, prefix=build.build_base)
|
||||
self.filelist.exclude_pattern(None, prefix=base_dir)
|
||||
|
||||
# pruning out vcs directories
|
||||
# both separators are used under win32
|
||||
if sys.platform == 'win32':
|
||||
seps = r'/|\\'
|
||||
else:
|
||||
seps = '/'
|
||||
|
||||
vcs_dirs = ['RCS', 'CVS', r'\.svn', r'\.hg', r'\.git', r'\.bzr',
|
||||
'_darcs']
|
||||
vcs_ptrn = r'(^|%s)(%s)(%s).*' % (seps, '|'.join(vcs_dirs), seps)
|
||||
self.filelist.exclude_pattern(vcs_ptrn, is_regex=1)
|
||||
|
||||
def write_manifest (self):
|
||||
"""Write the file list in 'self.filelist' (presumably as filled in
|
||||
by 'add_defaults()' and 'read_template()') to the manifest file
|
||||
named by 'self.manifest'.
|
||||
"""
|
||||
self.execute(file_util.write_file,
|
||||
(self.manifest, self.filelist.files),
|
||||
"writing manifest file '%s'" % self.manifest)
|
||||
|
||||
# write_manifest ()
|
||||
|
||||
|
||||
def read_manifest (self):
|
||||
"""Read the manifest file (named by 'self.manifest') and use it to
|
||||
fill in 'self.filelist', the list of files to include in the source
|
||||
distribution.
|
||||
"""
|
||||
log.info("reading manifest file '%s'", self.manifest)
|
||||
manifest = open(self.manifest)
|
||||
while 1:
|
||||
line = manifest.readline()
|
||||
if line == '': # end of file
|
||||
break
|
||||
if line[-1] == '\n':
|
||||
line = line[0:-1]
|
||||
self.filelist.append(line)
|
||||
manifest.close()
|
||||
|
||||
# read_manifest ()
|
||||
|
||||
|
||||
def make_release_tree (self, base_dir, files):
|
||||
"""Create the directory tree that will become the source
|
||||
distribution archive. All directories implied by the filenames in
|
||||
'files' are created under 'base_dir', and then we hard link or copy
|
||||
(if hard linking is unavailable) those files into place.
|
||||
Essentially, this duplicates the developer's source tree, but in a
|
||||
directory named after the distribution, containing only the files
|
||||
to be distributed.
|
||||
"""
|
||||
# Create all the directories under 'base_dir' necessary to
|
||||
# put 'files' there; the 'mkpath()' is just so we don't die
|
||||
# if the manifest happens to be empty.
|
||||
self.mkpath(base_dir)
|
||||
dir_util.create_tree(base_dir, files, dry_run=self.dry_run)
|
||||
|
||||
# And walk over the list of files, either making a hard link (if
|
||||
# os.link exists) to each one that doesn't already exist in its
|
||||
# corresponding location under 'base_dir', or copying each file
|
||||
# that's out-of-date in 'base_dir'. (Usually, all files will be
|
||||
# out-of-date, because by default we blow away 'base_dir' when
|
||||
# we're done making the distribution archives.)
|
||||
|
||||
if hasattr(os, 'link'): # can make hard links on this system
|
||||
link = 'hard'
|
||||
msg = "making hard links in %s..." % base_dir
|
||||
else: # nope, have to copy
|
||||
link = None
|
||||
msg = "copying files to %s..." % base_dir
|
||||
|
||||
if not files:
|
||||
log.warn("no files to distribute -- empty manifest?")
|
||||
else:
|
||||
log.info(msg)
|
||||
for file in files:
|
||||
if not os.path.isfile(file):
|
||||
log.warn("'%s' not a regular file -- skipping" % file)
|
||||
else:
|
||||
dest = os.path.join(base_dir, file)
|
||||
self.copy_file(file, dest, link=link)
|
||||
|
||||
self.distribution.metadata.write_pkg_info(base_dir)
|
||||
|
||||
# make_release_tree ()
|
||||
|
||||
def make_distribution (self):
|
||||
"""Create the source distribution(s). First, we create the release
|
||||
tree with 'make_release_tree()'; then, we create all required
|
||||
archive files (according to 'self.formats') from the release tree.
|
||||
Finally, we clean up by blowing away the release tree (unless
|
||||
'self.keep_temp' is true). The list of archive files created is
|
||||
stored so it can be retrieved later by 'get_archive_files()'.
|
||||
"""
|
||||
# Don't warn about missing meta-data here -- should be (and is!)
|
||||
# done elsewhere.
|
||||
base_dir = self.distribution.get_fullname()
|
||||
base_dir = self.distribution.get_name()
|
||||
# XXX
|
||||
# base_dir = "TEST"
|
||||
base_name = os.path.join(self.dist_dir, base_dir)
|
||||
|
||||
|
||||
self.make_release_tree(base_dir, self.filelist.files)
|
||||
archive_files = [] # remember names of files we create
|
||||
# tar archive must be created last to avoid overwrite and remove
|
||||
if 'tar' in self.formats:
|
||||
self.formats.append(self.formats.pop(self.formats.index('tar')))
|
||||
|
||||
for fmt in self.formats:
|
||||
# file = self.make_archive(base_name, fmt, base_dir=base_dir)
|
||||
file = make_zipfile(base_name, base_dir=base_dir)
|
||||
archive_files.append(file)
|
||||
self.distribution.dist_files.append(('spa', '', file))
|
||||
|
||||
self.archive_files = archive_files
|
||||
|
||||
if not self.keep_temp:
|
||||
dir_util.remove_tree(base_dir, dry_run=self.dry_run)
|
||||
|
||||
def get_archive_files (self):
|
||||
"""Return the list of archive files created when the command
|
||||
was run, or None if the command hasn't run yet.
|
||||
"""
|
||||
return self.archive_files
|
||||
|
||||
# class spa
|
||||
|
||||
|
||||
class install(Command):
|
||||
"""Does it make sense?"""
|
||||
|
||||
user_options = [('aa', 'a', 'aa')]
|
||||
|
||||
def initialize_options(self):
|
||||
pass
|
||||
|
||||
def finalize_options(self):
|
||||
pass
|
||||
|
||||
def run(self):
|
||||
print NotImplementedError("Command not implemented yet.")
|
||||
|
||||
|
||||
class test(Command):
|
||||
"""Does it make sense?"""
|
||||
|
||||
user_options = [('aa', 'a', 'aa')]
|
||||
|
||||
def initialize_options(self):
|
||||
pass
|
||||
|
||||
def finalize_options(self):
|
||||
pass
|
||||
|
||||
def run(self):
|
||||
if os.name == 'nt':
|
||||
subprocess.call(["py.test.exe"])
|
||||
|
||||
|
||||
|
||||
setup(cmdclass={'spa': spa, 'install': install, 'test': test},
|
||||
name='PowerShell',
|
||||
version=PACKAGE_VERSION,
|
||||
description='PowerShell support for Sublime Text.',
|
||||
author='Guillermo López',
|
||||
author_email='guilan70@hotmail.com',
|
||||
url='sublimetext.info',
|
||||
)
|
Reference in New Issue
Block a user