Platypus 5.3 documentation (manual translation, forgive me)

Documentation for Platypus 5.3

Introduction


What is Platypus?

Platypus is a development tool for creating macOS native applications based on scripts. Therefore, the script is converted into a regular application that can be launched in a window environment (such as Finder, Dock, etc.) without using the command line to run.
Platypus was first released in 2003 and has undergone many important updates. It is written in Object-C/Cocoa and is free and open source software released under the BSD license. This means that the source code is free, and you can modify and publish it at will.
Although Platypus is a free and open source software, it is the product of countless hours invested in more than a decade. So if Platypus makes your life easier, please donate to support further development.

How does Platypus work?

A regular macOS application is a bundle: a special folder with a specific directory structure. The
executable binary files, resources and configuration files are stored together in the package.
When the package is opened in the user interface, the binary executable file will run

Platypus uses a special binary executable file to start the script and captures the output of the script to create an application package.
The binary file can be configured to display the text output of the script in different ways, such as displaying the progress bar, text view, and status Item menu or web view based on WebKit.

What is Platypus not?

Platypus does not bind the macOS native API and scripting language. It is not a complete GUI development environment, so it is not suitable for creating complex and substantial applications with dynamic user interaction.
If you want to create more advanced macOS applications, you should learn to use Cocoa api for programming.
Platypus is not and will never replace learning to use (most excellent) native application programming interfaces

System Requirements

Platypus and the applications it generates require macOS 10.8 or higher, and 64-bit Intel binaries are provided.
If you want to use 10.6 or 32-bit systems, you can use Platypus 4.9.
If you want to use 10.4 or earlier PowerPC users, please use Platypus version 4.4

Credits (certification? declaration?)

Platypus was conceived and realized by Sveinbjorn Thordarson .
Its application icon is designed by Drífa Líftóra .
Thanks to
Troy Stephens : the original author of the IconFamily class for handling icons in Platypus
Bryan DK Jones : VDKQueue author
Gianni Ceccarelli : responsible for providing code for authenticated scripts
* *Matt Gallagher : responsible for temporary file security code
** Andy Matuschak
: responsible for updating the framework
Over the decades, the Stack Overflow and OmniGroup Mac development mailing lists have also played a very important role.
Finally, I am very grateful to Wilfredo Sanchez , the author of the DropScript project, who inspired me to complete the Platypus proof of concept project at the beginning.

basis


Main interface

The main interface of Platypus is straightforward. Once you start the Platypus application, you will see the following window:
Insert picture description here

App Name

The name of your application

Script Path

The path of the script to create the application. Or use the 选择button to select the script, or drag the script file in the Platypus window. You can also enter the path manually (the text field supports shell style and press the tab key to fill in automatically).

Insert picture description here

Once the script is selected, you can press the 编辑button to open it in the default text editor. Platypus uses a very basic built-in text editor by default. If you want to use a more feature-rich external editor, you can modify it in Preferences .

NewThe button will create a script file in the Platypus application folder and open it in the default editor. RevealThe button displays the script file in the Finder .

Interpreter

Use Script Type to specify a script interpreter for your script. Choose a predefined scripting language from the pop-up menu, or manually enter the path to the interpreter binary file.

In most cases, you do not need to specify it manually. Whenever a script file is opened, Platypus will #!automatically determine its script type according to the file suffix and the shebang line ( ). If you have specified it in the script file, Platypus is usually smart enough to solve this problem.

Please note that the interpreter must exist on the system where the application is running. All preset scripting language interpreters (except Node.js) are standard parts of all MacOS installations.

Args allows you to add parameters to the script or its interpreter.

Insert picture description here

Interface

Interface sets the user interface of the application. Platypus provides six different interface styles:
Insert picture description here

None

A windowless application that does not provide graphical feedback. All script output is redirected to STDERR.

Progress Bar

During the execution of the script, a small window with an uncertain progress bar and 取消buttons will appear . The script output is entered line by line into the text field above the progress bar. DetailsThe button displays a small text view containing the output of the complete script.

Insert picture description here

Text Window

Display a window containing a text view of script output. Please note that this text view is not a complete interactive terminal session and cannot be used to prompt the user to enter via STDIN . It does not support any standard terminal commands, nor can it be used to display ncurses- based interfaces.
The style of the text view can Text Settingsbe set in
Insert picture description here

Web View (web view)

The output of the script is rendered as HTML in the WebView window. This allows you to display script output to users using HTML format and other web technologies.

The root directory of the browser instance is the resource directory of the application package, so images and other supporting files can be added to the bundled file list and then referenced from that directory.
Insert picture description here

Status Menu

When starting the application, create a status item in the menu bar. Each time the status item is clicked, the script will be executed, and its text output will be displayed line by line in the menu. If a menu item is selected, the script will be executed again and the title of the selected item will be passed to the script as a parameter.
The attributes of the status item (icon, title, etc.) can be Status Item Settingsset in the button.

Droplet

Create a square window and instruct the user to put the file on it and run it. During operation, the script output will be displayed line by line, with an indeterminate cycle progress indicator.
Insert picture description here

Setting the Icon

Platypus allows you to set an icon for your application. You can choose from the preset icons, paste your own image or choose image or icns file.
Please note that when Platypus creates an icon from an ordinary image file, the effect is usually not ideal. Therefore, to get the best results, please use professional icon editing software to edit, and Select .icns fileimport carefully made .icnsfiles through the options .

Identifier, Author and Version (identifier, author and version)

This Identifiertext field specifies the unique identifier of the application . If you have set the application name, this will default to "org. username. application name".

Every MacOS application has a unique string called a package identifier, which is in the form of a reverse DNS name (for example, "com.apple.iTunes" or "org.sveinbjorn.Platypus"). Platypus uses the application name and default username to automatically format the package identifier, but you can set it to whatever you want. The default package identifier prefix can Preferencesbe modified in.

Insert picture description here
You can also set Author and Version metadata. This information will appear in the " GET Info " window of your application in the Finder and the " About " window accessible through the application's menu bar .

Special Options

Run with root privileges:

If checked, the application will prompt for the administrator password and use Apple's security framework to execute the script with upgraded (root) permissions. This does not exactly equivalent to the root user running the script. For more information, please refer to the MacOS Security Framework document.

The Platypus script cannot use the "sudo" command... This will cause the script to prompt the user to enter STDIN, and because there is no input, the application will hang indefinitely .

Please note that if this option is selected , STDERR output cannot be captured due to limitations in SecurityAPI . This can be circumvented by using a shell script to execute another script, transferring STDERR to STDOUT through a pipe (eg perl myScript.pl 2>&1).

Runs in background:

If selected, the application will register itself as a user interface element (LSUIElement) and will not appear in the Dock when it is launched.

Remain running after completion:

This option tells the application to stay open after the script is executed.

Bundled Files

Bundled Files contains files that should be copied to the Resources folder of the application package.
These files can then be used by scripts running in the same file directory

Insert picture description here

advanced options


Accept files and drag items

Checking Accept dropped items enables the application package to accept dropped files or text fragments.
You can use the drop-down setting to specify the application package which types of files can be dragged and be able to accept data.
Insert picture description here

Guess you like

Origin blog.csdn.net/qq_20176001/article/details/97021320
5.3