Giter VIP home page Giter VIP logo

Comments (3)

manudss avatar manudss commented on September 28, 2024 1

Hello,

Thanks, for your answer. Yes, I have succeeded to make something works. I would like to have something, to run local application. (I think, this features, should be a basics for the desktop version).

But for powershell command, the call was not done in the correct format. The script was called like this :

PowerShell -File your-command-script.ps1 --shortcut=github_shortcut

But should be called with this format :
PowerShell -File your-command-script.ps1 -shortcut github_shortcut

https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_functions_advanced_parameters?view=powershell-7.2

It's works me with a workaround by using the args[0] and then replace the params name (.replace('--shortcut=', '') .

regards.

from platform.

taras-slapdash avatar taras-slapdash commented on September 28, 2024

Hey @manudss!

Thanks for your question.

I'm not an expert in PowerShell or Windows but I'll do my best to help you out.

Today, Action doesn't allow you to execute any custom code. We may support something like this in the future but at the moment you can use "add-param" as the main action for your options:

{
  "view": {
    "type": "list",
    "options": [
      {
        "title": "Open Github Shortcut",
        "action": {
          "type": "add-param",
          "name": "shortcut",
          "value": "github_shortcut"
        }
      }
      ...
    ]
  }
}

So when the user selects an option, your command (script) will be run with the shortcut parameter. The value of this parameter will match the value of the corresponding option. For example, if the user selected "Open Github Shortcut", Slapdash would run your script in the following way:

PowerShell -File your-command-script.ps1 --shortcut=github_shortcut

Now, in your script, you'd need to check whether the command was run with the shortcut parameter. If it was then you would need to match the parameter's value to the actual shortcut and run the respective command. Otherwise, your command should return a List View with options.

Alternatively, instead of using the shortcut's name as a parameter's value, you can use the file path instead. This may make things simpler for your script.

In our docs, there is a tutorial for the Copy Special Character command which demonstrates how a custom parameter is used to run a command.

I hope it's helpful but please let me know if I misunderstood how your command should work or if you have any questions.

from platform.

taras-slapdash avatar taras-slapdash commented on September 28, 2024

Glad you found the workaround.

We opt in to using the same style for passing arguments across all scripts. But it's understandable that in some scripts this will require additional parsing and conversion.

I think in the future we'll have some wrappers and helper functions to reduce the boilerplate code a developer has to write. For instance, we can build functions to parse arguments for each scripting language that we support.

I noted your feedback. Thank you!

from platform.

Related Issues (10)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.