tomzx / vscode-run-me

Configurable commands with easy to setup forms.
MIT License
1 stars 1 forks source link

how to get current file path in run-me command? #3

Open superzw opened 5 years ago

superzw commented 5 years ago

I want to do sth with the file in current opening tab, as mv it to somewhere.

like this:

"run-me": {
    "commands": [{
        "identifier":"d",
        "command":"mv $current_file ...",
    }]
}

how can i get current opening file path?

bmix commented 4 years ago

I have the same need. The commandline I would like to execute is:

path/to/saxon.bat $currentFile $stylesheetName $tmp/saxon_out.$currentFileExtension

I need vcscode-run-me, since it seems to be the only such addon, that would allow to manually enter additional options (i.e. the stylesheet name) via the input dialog.

Thanks.

tomzx commented 4 years ago

It is currently not possible to retrieve the current file in the command.

I think what would be the best in this case is to allow users to directly access the vscode object from the commands so that they can create any kind of complex rule.

It would then be possible to write

"run-me": {
    "commands": [{
        "identifier":"d",
        "command":"mv $vscode.window.activeTextEditor.document.uri.fsPath ...",
    }]
}

It's definitely not pretty on the eyes, but it could be a first step. The next step could be to allow for variables to point to other variables, so you could write

"run-me": {
    "variables": {
        "currentFile": "$vscode.window.activeTextEditor.document.uri.fsPath"
    },
    "commands": [{
        "identifier":"d",
        "command":"mv $currentFile ...",
    }]
}