Meta [ Title: "Remote command-line interface for the Meta programming language compiler server" Author: "Kaj de Vos" Rights: "Copyright (c) 2021 Kaj de Vos. All rights reserved." License: { BSD-2-Clause https://opensource.org/licenses/BSD-2-Clause Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. } See: { The Meta Project: https://metaproject.frl https://language.metaproject.frl/#run } Purpose: { Compile a Meta program (for Atari 8-bit) on the Meta build server. } Example: { Unix: (mv compile.com compile) chmod +x compile ./compile Windows: compile } Tabs: 4 ] Version= "0.6" Out= ./program.xex Meta= ./metadata.txt Integer8! status Either argument= first-of system/program/arguments [ either argument = "about" [ write/line {Meta remote compiler Compile a Meta program for Atari 8-bit via the Meta build service. Copyright (c) 2021 Kaj de Vos The Meta Project https://metaproject.frl https://language.metaproject.frl/#run} ][ either argument = "version" [ write/line version ][ either in: second-of system/program/arguments [ target= argument ][ in: argument ] ] ] ][ Write/line either all [width= system/console/width width < 80] [ {https://language.metaproject.frl/#run Usage: compile Show this help text. compile compile Compile program on the server Syntax: A term to be filled in Commands: about Show program info version Show program version} ][ {Usage: compile Show this help text. compile compile Send Atari 8-bit program to server to compile. Syntax: A term to be filled in. Commands: about Show program info. version Show program version. Guide: https://language.metaproject.frl/#run} ] Status: -1 ; Return warning number for scripts, in case an action was meant ] If in [ Write "Compiling Atari 8-bit file " Write/line in Write new-line Either result= run join/with join/with join/with join/with join/with join/with join/with "curl -X POST --data-binary @" in " --dump-header " meta " https://atari8.metaproject.frl/compile/" version "/Atari/CC65 --output " out [ either system/catalog/errors/system/unknown = error: to error! result [ ; 127 << 8 Write/error/line {Error: the "curl" program could not be found.} Write/error/line {Is it installed on your system and accessible?} ][ Write/error "(Networking) error: " Write/error/line error ] ][ Write new-line Either headers= try open meta [ Until any [ is-tail headers text?= find/match find/match/tail take/line headers "Content-type: " "text/plain" ] [] Close headers Either text? [ either report= try open out [ Write report Close report ][ ; Save the occurred error from overwriting Error: system/error Write/error "File error: could not access " Write/error out Write/error ": " Write/error/line error ] ][ Write "Result is in file " Write/line out ] ][ Error: system/error Write/error "File error: could not access " Write/error meta Write/error ": " Write/error/line error ] ] ] Status