How to Create a Command-Line Tool with LiveCode?
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- VIP Livecode Opensource Backer
- Posts: 92
- Joined: Wed May 29, 2013 1:54 am
- Location: Sydney, Australia
How to Create a Command-Line Tool with LiveCode?
I know it is possible to write 'livecode script' (.lc) files, which can then be interpreted by LiveCode Server, but I was wondering whether it is possible to create an actual command-line tool with LiveCode? - ie., an all-in-one standalone binary intended to be run from the command-line only.
I have been unable to find any instructions or references anywhere.
I have been unable to find any instructions or references anywhere.
-
- VIP Livecode Opensource Backer
- Posts: 9842
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
Re: How to Create a Command-Line Tool with LiveCode?
Standalones can be run facelessly by adding -ui to the command line options.
This getopt library well help parse command line args:
http://lists.runrev.com/pipermail/use-l ... 28347.html
This getopt library well help parse command line args:
http://lists.runrev.com/pipermail/use-l ... 28347.html
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
-
- VIP Livecode Opensource Backer
- Posts: 92
- Joined: Wed May 29, 2013 1:54 am
- Location: Sydney, Australia
Re: How to Create a Command-Line Tool with LiveCode?
Wow, that was a quick reply!
Trying to open the bundle and access the binary directly causes an error:
The 'open' command doesn't support `-ui` flags either, and yields the same error.
Ultimately, I would like to be able to use my compiled tool simply like this:
Is that possible?
What command are you using to run the standalone? I'm on a Mac, and trying to simply 'run' the standalone on the command-line - with or without '-ui' flags - does not work:FourthWorld wrote: ↑Fri Aug 24, 2018 7:13 amStandalones can be run facelessly by adding -ui to the command line options.
Code: Select all
$ mylivecodetool.app -ui
-bash: mylivecodetool.app: is a directory
Code: Select all
$ mylivecodetool.app/Contents/MacOS/mylivecodetool -ui
TIS/TSM in non-main thread environment, ERROR : This is NOT allowed. Please call TIS/TSM in main thread!!!
Ultimately, I would like to be able to use my compiled tool simply like this:
Code: Select all
$ mylivecodetool -a -b -c blablabla
Re: How to Create a Command-Line Tool with LiveCode?
Andy Piddock
https://livecode1001.blogspot.com Built with LiveCode
https://github.com/AndyPiddock/TinyIDE Mini IDE alternative
https://github.com/AndyPiddock/Seth Editor color theming
http://livecodeshare.runrev.com/stack/897/ LiveCode-Multi-Search
https://livecode1001.blogspot.com Built with LiveCode
https://github.com/AndyPiddock/TinyIDE Mini IDE alternative
https://github.com/AndyPiddock/Seth Editor color theming
http://livecodeshare.runrev.com/stack/897/ LiveCode-Multi-Search
-
- VIP Livecode Opensource Backer
- Posts: 92
- Joined: Wed May 29, 2013 1:54 am
- Location: Sydney, Australia
Re: How to Create a Command-Line Tool with LiveCode?
Thank you for the link, @AndyP - it does have some useful script code there that will come handy! Unfortunately, it does not answer any of my questions...
-
- VIP Livecode Opensource Backer
- Posts: 9842
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
Re: How to Create a Command-Line Tool with LiveCode?
Mac apps are actually folders, rather than single file executables. You'll find the executable within the .app bundle nested a couple folders in (sorry, don't have my Mac on right now and I forget the exact folder names, but if you the around inside the bundle you'll find it easily enough).
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
-
- VIP Livecode Opensource Backer
- Posts: 92
- Joined: Wed May 29, 2013 1:54 am
- Location: Sydney, Australia
Re: How to Create a Command-Line Tool with LiveCode?
Thank you for the guidance, @FourthWorld! As I mentioned a couple of posts above, I've actually already looked inside the app bundle(=.app folder), found the executable, and tried running that both with and without the '-ui' flag. It runs into a fatal error:
I have tried saving the standalone both with LC9 stable, as well as the latest RC2 version - no difference. Am I missing something obvious?
Code: Select all
$ mylivecodetool.app/Contents/MacOS/mylivecodetool -ui
2018-08-24 23:34:18.666 mylivecodetool[43918:17761058] pid(43918)/euid(501) is calling TIS/TSM in non-main thread environment, ERROR : This is NOT allowed. Please call TIS/TSM in main thread!!!
-
- VIP Livecode Opensource Backer
- Posts: 9842
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
Re: How to Create a Command-Line Tool with LiveCode?
Yep, you were on top of the path thing indeed. I was on auto-pilot, and most of the issues I've seen with CLI on macOS have been about the path into the bundle.
Once I got your latest message I found the issue intriguing, as I do a lot of automation work which requires me to run standalones from the command line. And sure enough, I got the same message.
I filed a bug report - see my notes here:
https://quality.livecode.com/show_bug.cgi?id=21524
One possible difference between your experience and mine: here, though I get the error message output, the app runs normally. This is consistent with reports of this behavior with other apps in macOS 10.13 I found in a web search.
Is your app not running at all?
Once I got your latest message I found the issue intriguing, as I do a lot of automation work which requires me to run standalones from the command line. And sure enough, I got the same message.
I filed a bug report - see my notes here:
https://quality.livecode.com/show_bug.cgi?id=21524
One possible difference between your experience and mine: here, though I get the error message output, the app runs normally. This is consistent with reports of this behavior with other apps in macOS 10.13 I found in a web search.
Is your app not running at all?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
-
- VIP Livecode Opensource Backer
- Posts: 92
- Joined: Wed May 29, 2013 1:54 am
- Location: Sydney, Australia
Re: How to Create a Command-Line Tool with LiveCode?
TBH, I merely had a 'skeleton' of an app as a test - the app did nothing - as I was just starting to tinker with a command-line setup.
Is it possible to 'echo' something to the terminal, as a test? How do we go about building a '-h' or '--help'?
Is it possible to 'echo' something to the terminal, as a test? How do we go about building a '-h' or '--help'?
-
- VIP Livecode Opensource Backer
- Posts: 9842
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
Re: How to Create a Command-Line Tool with LiveCode?
When run from the command line the "put" command will output to the terminal.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
-
- VIP Livecode Opensource Backer
- Posts: 92
- Joined: Wed May 29, 2013 1:54 am
- Location: Sydney, Australia
Re: How to Create a Command-Line Tool with LiveCode?
Thank you, Richard!
Yes, it does output my 'Hello World' - so it is working, although only after it gives me the warning (repeatedly)...
Thank you for filing the bug report! Does this mean that the only way to create a 'command-line tool' in LiveCode right now would be to run it as a hash-bang script under LiveCode Server?
Yes, it does output my 'Hello World' - so it is working, although only after it gives me the warning (repeatedly)...
Thank you for filing the bug report! Does this mean that the only way to create a 'command-line tool' in LiveCode right now would be to run it as a hash-bang script under LiveCode Server?
-
- VIP Livecode Opensource Backer
- Posts: 9842
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
Re: How to Create a Command-Line Tool with LiveCode?
That's an interesting question. When you run it that way does it output no errors?
You may be able to just drop backa version or two to do what you were originally planning. I think this is a fairly recent regression.
What are you working on? Very few of us use LC the command line, but it's so capable I prefer it to anything else.
You may be able to just drop backa version or two to do what you were originally planning. I think this is a fairly recent regression.
What are you working on? Very few of us use LC the command line, but it's so capable I prefer it to anything else.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
-
- VIP Livecode Opensource Backer
- Posts: 92
- Joined: Wed May 29, 2013 1:54 am
- Location: Sydney, Australia
Re: How to Create a Command-Line Tool with LiveCode?
There is a command-line tool that we use for one of our CMSs, and unfortunately the developer has decided to drop support for it - they don't want to develop it any further, as it's getting too many requests for enhancements, and "taking away from time spent developing the CMS itself". I thought this sounded like a good development opportunity!
This particular tool only does some fairly basic stuff atm: download git repositories (which the developers using it are already supposed to have in their machines), create some files (via interactive wizards), and update some components (via git, again). I'd love to be able to try and do it in LiveCode, but am starting to think that it may be easier to actually develop a GUI for it, than trying to do it as a command-line tool...
This particular tool only does some fairly basic stuff atm: download git repositories (which the developers using it are already supposed to have in their machines), create some files (via interactive wizards), and update some components (via git, again). I'd love to be able to try and do it in LiveCode, but am starting to think that it may be easier to actually develop a GUI for it, than trying to do it as a command-line tool...
-
- VIP Livecode Opensource Backer
- Posts: 9842
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
Re: How to Create a Command-Line Tool with LiveCode?
I was intrigued by your suggestion, and indeed it works well: when I run a text file containing a script with the shebang line pointing to my copy of LC Server 9.0.1rc2 it runs the script and produces no errors.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
-
- VIP Livecode Opensource Backer
- Posts: 9842
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
Re: How to Create a Command-Line Tool with LiveCode?
Bug already fixed, in queue for next build:
https://quality.livecode.com/show_bug.cgi?id=21524
https://quality.livecode.com/show_bug.cgi?id=21524
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn