Andrew Posted January 14, 2013 Share Posted January 14, 2013 For the last few weeks, I've been refining how optional arguments, specifically in Script Filter workflow objects work. This is now what I hope to be the final format. The most interesting one is Optional Argument with Space You can grab b64 with these changes on http://media.alfredapp.com/v2beta/ so make sure your workflow Script Filters work with below No Argument - You script is only run when the typed keyword is matched - Pressing return or tab will autocomplete keyword Optional Argument [no space] - Your script is run as soon as the typed keyword is matched - Pressing return or tab with a partial keyword will autocomplete keyword Optional Argument [with space] - Your script is run as soon as the typed keyword is matched, regardless of space - Pressing return or tab with a partial keyword will autocomplete with suffixed space Required Argument [no space] - Your script is run after the typed keyword is matched AND you start typing an argument - Pressing return or tab with a partial keyword will autocomplete keyword Required Argument [with space] - Your script is run after the typed keyword is matched with a trailing space AND you start typing an argument - Pressing return or tab with a partial keyword will autocomplete with suffixed space Cheers, Andrew Tyler Eich and Amoftcoorb 2 Link to comment
aiyo Posted January 14, 2013 Share Posted January 14, 2013 Should the prefixed space be part of the argument? I suggest it should not be. Link to comment
aiyo Posted January 14, 2013 Share Posted January 14, 2013 And can the space be prefixed as soon as you start typing the argument, instead of being suffixed the keyword on autocompletion? This will also solve the inconsistency between user completed keywords (no suffixed space) vs. autocompletion (suffixed space). Link to comment
Andrew Posted January 14, 2013 Author Share Posted January 14, 2013 no on the auto prefix as Alfred doesn't do that anywhere else... and it's inconsistent with actioning a matched keyword. I'll remove the space prefix though as that's absolutely right. Link to comment
Andrew Posted January 14, 2013 Author Share Posted January 14, 2013 I've just put out b64 which removes the space prefix now on optional arguments, if you could grab and test this! thanks Link to comment
aiyo Posted January 15, 2013 Share Posted January 15, 2013 b64 is working very well for me Link to comment
vivek Posted January 16, 2013 Share Posted January 16, 2013 How does the script filter work, I am trying something like if [ $# == 1 ] then set query = "url1" elif [ $# == 2 ] then set query = "url2" fi and linked it to an Open URL action where I have just mentioned the search URL as {query}, but its not working. Link to comment
Andrew Posted January 16, 2013 Author Share Posted January 16, 2013 How does the script filter work, I am trying something like Take a look at this thread: http://www.alfredforum.com/index.php?/topic/5-generating-feedback-in-workflows/ Link to comment
peelman Posted January 26, 2013 Share Posted January 26, 2013 Andrew, if I attempt to use a space in my argument, Alfred drops out of the script filter completely. I.e. if I have a script filter for my TV shows folder (keyword 'tv'), and i type: tv the daily when searching for "the daily show", I can't find a way to make that work. I'm just using a rough php preg_match, so I can just do 'tv daily' and that finds it ok, but at this point my curiosity is piqued, so i want to see if its by design that you can't use arguments with spaces, or if there's something afoot here... Link to comment
CarlosNZ Posted January 26, 2013 Share Posted January 26, 2013 ... but at this point my curiosity is piqued, so i want to see if its by design that you can't use arguments with spaces, or if there's something afoot here... You can totally use arguments with spaces. Must be "something afoot" at your end. (Quoting issue, perhaps?) Link to comment
woofy31 Posted March 18, 2013 Share Posted March 18, 2013 (edited) Hey, A question regarding arguments.. I've seen people make workflows that accept arguments containing spaces, but I can't seem to be able to make this work, because the moment I type a space in my argument the workflow switches to "search on google" For example, typing "google en text" would search "text" on google.com, while "google de text" would search on google.de (and not to mention the more problematic "google de space separated text" that should search "space separated text" on google.de... Any ideas, advice, how-tos? [later edit] I guess the language mode could be set up using "google en" and "google de" as keywords to trigger the workflow (although it seems like overkill to cover more languages and create a keyword for each one), but the next argument still doesn't work if it has spaces in it Edited March 18, 2013 by woofy31 Link to comment
jdfwarrior Posted March 18, 2013 Share Posted March 18, 2013 Hey, A question regarding arguments.. I've seen people make workflows that accept arguments containing spaces, but I can't seem to be able to make this work, because the moment I type a space in my argument the workflow switches to "search on google" For example, typing "google en text" would search "text" on google.com, while "google de text" would search on google.de (and not to mention the more problematic "google de space separated text" that should search "space separated text" on google.de... Any ideas, advice, how-tos? [later edit] I guess the language mode could be set up using "google en" and "google de" as keywords to trigger the workflow (although it seems like overkill to cover more languages and create a keyword for each one), but the next argument still doesn't work if it has spaces in it Without seeing the code and knowing what your doing, I'm not sure I can be of a whole lot of help right off. Have you wrapped the {query} in quotes to make sure its not dropped because of the space? Link to comment
peelman Posted March 18, 2013 Share Posted March 18, 2013 On my end it ended up being a copy and paste error. I was using David's example script and was still passing the {query} through `urlencode`, which was screwing me up. Removing that fixed the problem. Now doing quick and dirty regex searches like a boss. Link to comment
jdfwarrior Posted March 18, 2013 Share Posted March 18, 2013 On my end it ended up being a copy and paste error. I was using David's example script and was still passing the {query} through `urlencode`, which was screwing me up. Removing that fixed the problem. Now doing quick and dirty regex searches like a boss. Oh so you're going to blame it on me huh? jk, glad you were able to figure it out Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now