उपयोग लिखें मेजबान cmdlet के रूप में उपयोग कर सकते हैं आपकी पाइपलाइन का अंतिम विवरण। सामान्य अनौपचारिक पावरहेल आउटपुट माता-पिता कंसोल विंडो के आयामों को देखने के लिए प्रतीत होता है, और trims/waps आउटपुट लाइनों को चौड़ाई -1 तक दिखाई देता है। लिखित-होस्ट cmdlet इस चरण को छोड़ देता है और बिना किसी आगे मुंगिंग के सीधे stdout लिखता है।
यहाँ एक उदाहरण है, जो एक JSON फ़ाइल पढ़ता है, और जावास्क्रिप्ट उत्पादन जो एक बड़ा स्ट्रिंग के लिए JSON कहते हैं (संरक्षण टिप्पणियाँ) लिखते हैं:
// File: manifest.json
//
// Description:
// manifest for chrome plug-in
{
"manifest_version": 2,
"version": "0.0.0",
// the ID is: sdfjkghsdfjkghjksdfghjkfhjkdfjff
"key": "sdfjkhsdfjkghjksdfghkjsdhgsdjkgfhjklsdfhgjklsdfhgjklsdhfgkljsdfhgkljsdhklgjsdhfjklghsdfjklghsdjklfghjksdfhgjksdhfgjklhsdfjkl",
"content_scripts": [ { "matches": ["http://*/*", "https://*/*"], "js": ["content.js"], "run_at": "document_start" } ],
// this is the standard LOCAL install location - but if this extension is published to the app-store, this value gets overridden (that is okay and even good)
"update_url": "file:///C:/Program%20Files/MyProduct/Update.xml",
}
:
powershell -Command "$input | ForEach-Object { \"manifestBlob += \"\"\" + ($_ -replace \"\"\"\", \"\\\"\"\") + \"\n\"\";\" } | Write-Host" <manifest.json> buildmanifest.js
यहां एक नमूना इनपुट फ़ाइल है
और उत्पादन जब राइट-होस्ट का उपयोग करते हुए:
manifestBlob += "\n";
manifestBlob += "// File: manifest.json\n";
manifestBlob += "//\n";
manifestBlob += "// Description:\n";
manifestBlob += "// manifest for chrome plug-in\n";
manifestBlob += "\n";
manifestBlob += "{\n";
manifestBlob += " \"manifest_version\": 2,\n";
manifestBlob += "\n";
manifestBlob += " \"version\": \"0.0.0\",\n";
manifestBlob += "\n";
manifestBlob += " // the ID is: sdfjkghsdfjkghjksdfghjkfhjkdfjff\n";
manifestBlob += " \"key\": \"sdfjkhsdfjkghjksdfghkjsdhgsdjkgfhjklsdfhgjklsdfhgjklsdhfgkljsdfhgkljsdhklgjsdhfjklghsdfjklghsdjklfghjksdfhgjksdhfgjklhsdfjkl\",\n";
manifestBlob += "\n";
manifestBlob += " \"content_scripts\": [ { \"matches\": [\"http://*/*\", \"https://*/*\"], \"js\": [\"content.js\"], \"run_at\": \"document_start\" } ],\n";
manifestBlob += "\n";
manifestBlob += " // this is the standard LOCAL install location - but if this extension is published to the app-store, this value gets overridden (that is okay and even good)\n";
manifestBlob += " \"update_url\": \"file:///C:/Program%20Files/MyProduct/Update.xml\",\n";
manifestBlob += "}\n";
और अंत में, Ter का एक उदाहरण rible चीजें हैं जो तब होगा, जब राइट-होस्ट cmdlet बाहर छोड़ (60 के एक सांत्वना चौड़ाई कल्पना करते हुए):
manifestBlob += "\n";
manifestBlob += "// File: manifest.json\n";
manifestBlob += "//\n";
manifestBlob += "// Description:\n";
manifestBlob += "// manifest for chrome plug-in\n";
manifestBlob += "\n";
manifestBlob += "{\n";
manifestBlob += " \"manifest_version\": 2,\n";
manifestBlob += "\n";
manifestBlob += " \"version\": \"0.0.0\",\n";
manifestBlob += "\n";
manifestBlob += " // the ID is: sdfjkghsdfjkghjksdfghjkf
hjkdfjff\n";
manifestBlob += " \"key\": \"sdfjkhsdfjkghjksdfghkjsdhgs
djkgfhjklsdfhgjklsdfhgjklsdhfgkljsdfhgkljsdhklgjsdhfjklghsd
fjklghsdjklfghjksdfhgjksdhfgjklhsdfjkl\",\n";
manifestBlob += "\n";
manifestBlob += " \"content_scripts\": [ { \"matches\":
[\"http://*/*\", \"https://*/*\"], \"js\": [\"content.js\"]
, \"run_at\": \"document_start\" } ],\n";
manifestBlob += "\n";
manifestBlob += " // this is the standard LOCAL install
location - but if this extension is published to the app-st
ore, this value gets overridden (that is okay and even good
)\n";
manifestBlob += " \"update_url\": \"file:///C:/Program%2
0Files/MyProduct/Update.xml\",\n";
manifestBlob += "}\n";
'बाहर File' एक' -Width' पैरामीटर भी है। इसके दस्तावेज में कहा गया है कि चौड़ाई से परे सब कुछ छोटा कर दिया गया है (लपेटा नहीं गया है)। तो मुझे लगता है कि यह पहले 4096 वर्णों (क्या एक अजीब गैर-दौर संख्या) और फिर कंसोल विंडो की चौड़ाई पर छंटनी करता है। हालांकि यह लपेट नहीं जाएगा, यह लंबी लाइनों को कम कर देता है जिसका इरादा नहीं हो सकता है। – Joey
4096 अजीब नहीं है और गैर-दौर नहीं है। यह 2^12 –