PR feedback changes
This commit is contained in:
parent
88a8ad9da6
commit
dcf7ea84e0
|
@ -7,7 +7,7 @@
|
|||
# language without adding any extra dependencies to our tests.
|
||||
|
||||
const NUSHELL_VERSION = "0.96.2"
|
||||
const PLUGIN_VERSION = "0.1.0" # bump if you change commands!
|
||||
const PLUGIN_VERSION = "0.1.1" # bump if you change commands!
|
||||
|
||||
def main [--stdio] {
|
||||
if ($stdio) {
|
||||
|
@ -133,7 +133,7 @@ def process_call [
|
|||
|
||||
# Create a Value of type List that will be encoded and sent to Nushell
|
||||
let value = {
|
||||
Value: { value: {
|
||||
Value: [{
|
||||
List: {
|
||||
vals: (0..9 | each { |x|
|
||||
{
|
||||
|
@ -157,8 +157,7 @@ def process_call [
|
|||
}),
|
||||
span: $span
|
||||
}
|
||||
}
|
||||
}
|
||||
}, null]
|
||||
}
|
||||
|
||||
write_response $id { PipelineData: $value }
|
||||
|
|
|
@ -28,7 +28,7 @@ import json
|
|||
|
||||
|
||||
NUSHELL_VERSION = "0.96.2"
|
||||
PLUGIN_VERSION = "0.1.0" # bump if you change commands!
|
||||
PLUGIN_VERSION = "0.1.1" # bump if you change commands!
|
||||
|
||||
|
||||
def signatures():
|
||||
|
@ -125,31 +125,31 @@ def process_call(id, plugin_call):
|
|||
span = plugin_call["call"]["head"]
|
||||
|
||||
# Creates a Value of type List that will be encoded and sent to Nushell
|
||||
def f(x, y): return {
|
||||
"Int": {
|
||||
"val": x * y,
|
||||
"span": span
|
||||
}
|
||||
}
|
||||
def f(x, y):
|
||||
return {"Int": {"val": x * y, "span": span}}
|
||||
|
||||
value = {
|
||||
"Value": {
|
||||
"List": {
|
||||
"vals": [
|
||||
{
|
||||
"Record": {
|
||||
"val": {
|
||||
"one": f(x, 0),
|
||||
"two": f(x, 1),
|
||||
"three": f(x, 2),
|
||||
},
|
||||
"span": span
|
||||
"Value": [
|
||||
{
|
||||
"List": {
|
||||
"vals": [
|
||||
{
|
||||
"Record": {
|
||||
"val": {
|
||||
"one": f(x, 0),
|
||||
"two": f(x, 1),
|
||||
"three": f(x, 2),
|
||||
},
|
||||
"span": span,
|
||||
}
|
||||
}
|
||||
} for x in range(0, 10)
|
||||
],
|
||||
"span": span
|
||||
}
|
||||
}
|
||||
for x in range(0, 10)
|
||||
],
|
||||
"span": span,
|
||||
}
|
||||
},
|
||||
None,
|
||||
]
|
||||
}
|
||||
|
||||
write_response(id, {"PipelineData": value})
|
||||
|
@ -172,7 +172,7 @@ def tell_nushell_hello():
|
|||
"Hello": {
|
||||
"protocol": "nu-plugin", # always this value
|
||||
"version": NUSHELL_VERSION,
|
||||
"features": []
|
||||
"features": [],
|
||||
}
|
||||
}
|
||||
sys.stdout.write(json.dumps(hello))
|
||||
|
@ -200,22 +200,26 @@ def write_error(id, text, span=None):
|
|||
Use this error format to send errors to nushell in response to a plugin call. The ID of the
|
||||
plugin call is required.
|
||||
"""
|
||||
error = {
|
||||
"Error": {
|
||||
"msg": "ERROR from plugin",
|
||||
"labels": [
|
||||
{
|
||||
"text": text,
|
||||
"span": span,
|
||||
}
|
||||
],
|
||||
error = (
|
||||
{
|
||||
"Error": {
|
||||
"msg": "ERROR from plugin",
|
||||
"labels": [
|
||||
{
|
||||
"text": text,
|
||||
"span": span,
|
||||
}
|
||||
],
|
||||
}
|
||||
}
|
||||
} if span is not None else {
|
||||
"Error": {
|
||||
"msg": "ERROR from plugin",
|
||||
"help": text,
|
||||
if span is not None
|
||||
else {
|
||||
"Error": {
|
||||
"msg": "ERROR from plugin",
|
||||
"help": text,
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
write_response(id, error)
|
||||
|
||||
|
||||
|
@ -230,11 +234,14 @@ def handle_input(input):
|
|||
elif "Call" in input:
|
||||
[id, plugin_call] = input["Call"]
|
||||
if plugin_call == "Metadata":
|
||||
write_response(id, {
|
||||
"Metadata": {
|
||||
"version": PLUGIN_VERSION,
|
||||
}
|
||||
})
|
||||
write_response(
|
||||
id,
|
||||
{
|
||||
"Metadata": {
|
||||
"version": PLUGIN_VERSION,
|
||||
}
|
||||
},
|
||||
)
|
||||
elif plugin_call == "Signature":
|
||||
write_response(id, signatures())
|
||||
elif "Run" in plugin_call:
|
||||
|
@ -258,4 +265,4 @@ if __name__ == "__main__":
|
|||
if len(sys.argv) == 2 and sys.argv[1] == "--stdio":
|
||||
plugin()
|
||||
else:
|
||||
print("Run me from inside nushell!")
|
||||
print("Run me from inside nushell!")
|
||||
|
|
|
@ -178,7 +178,7 @@ fn handle_message(
|
|||
id,
|
||||
{
|
||||
"PipelineData": {
|
||||
"Value": {"value": return_value}
|
||||
"Value": [return_value, None::<Value>]
|
||||
}
|
||||
}
|
||||
]
|
||||
|
|
Loading…
Reference in New Issue
Block a user