websIDE
  • webside
    • Overview
  • API
    • General
      • Dialect
      • Version
      • Colors
      • Logo
      • Stats
      • Themes
      • Icons
      • Save Image
    • Changes
      • Retrieve changes
      • Apply a change
    • Changesets
      • Convert chunks to JSON changes
      • Convert JSON changes to chunks
    • Code
      • Autocompletions
        • Retrieve autocompletions
      • Categories
        • Retrieve categories
        • Retrieve usual categories
      • Classes
        • Retrieve classes
        • Retrieve a class
        • Retrieve categories
        • Retrieve variables
        • Retrieve class variables
        • Retrieve instance variables
        • Retrieve selectors
        • Retrieve methods
        • Retrieve method
        • Retrieve method history
        • Retrieve subclasses
        • Retrieve superclasses
        • Retrieve used categories
      • Methods
        • Retrieve methods
      • Packages
        • Retrieve packages
        • Retrieve a package
        • Retrieve package classes
        • Retrieve package methods
      • Search
      • Selectors
        • Find selector in source code
      • Templates
        • Retrieve class template
        • Retrieve method template
    • Debuggers
      • Retrieve active debuggers
      • Create a debugger
      • Delete debugger
      • Retrieve debugger frames
      • Retrieve debugger frame
      • Retrieve frame bindings
      • Restart debugger
      • Resume debugger
      • Step into debugger
      • Step over debugger
      • Step through debugger
      • Terminate debugger
    • Evaluations
      • Retrieve evaluations
      • Evaluate an expression
      • Cancel evaluation
      • Retrieve evaluation
      • Pause evaluation
      • Resume evaluation
    • Extensions
      • Retrieve extensions
      • Changes extensions
      • Export extensions
      • Search extensions
    • Commands
      • Retrieve command definitions
      • Invoke commands
    • Objects
      • Retrieve pinned objects
      • Pin object
      • Retrieve pinned object
      • Retrieve pinned object slots
        • Custom views
      • Unpin an object
      • Unpin all objects
    • Processes
      • Retrieve active processes
    • Profilers
      • Retrieve active profilers
      • Create a new profiler
      • Delete a profiler
      • Retrieve a profiler
      • Retrieve profiler ranking results
      • Retrieve profiler tree results
    • Testing
      • Run tests
      • Retrieve test run status
      • Retrieve test run results
    • Workspaces
      • Retrieve active workspaces
      • Create a new workspace
      • Delete a workspace
      • Retrieve a workspace
      • Update a workspace
      • Retrieve workspace bindings
Powered by GitBook
On this page
  • Success Responses
  • Example 1: Pharo image cleanup
  • Example 2: saving image with a different name
  1. API
  2. Commands

Invoke commands

PreviousRetrieve command definitionsNextObjects

Last updated 2 months ago

Process a command.

URL: /commands

Method: POST

Success Responses

Code : 200 OK

Payload: command defined as:

{
	"command": "string",
}

It can also contain more properties given by the parameters defined by the command ()

Example 1: Pharo image cleanup

Taking the definition given in , the payload the backend will receive should be like this:

{
	"comand": "imageCleanup"
}

The Pharo implementation of the API, could be have some sort of command dispatcher in place based on the command property. For example:

processCommand
	| command |
	command := self bodyAt: 'command'.
	(self respondsTo: command asSymbol)
		ifFalse: [^self badRequest: 'Invalid command'].
	self perform: command asSymbol.
	^ true

and the particular handler for imageCleanUp:

imageCleanup

	Smalltalk cleanUp: false

Note: this is just an example, implemented in Pharo 12, and may be not a good implementation as #cleanUp: has undesired effects on native UI (some progress bar).

Example 2: saving image with a different name

{
	"command": "saveImageAs",
	"imageName": "MyImage"
}

Again the backend could handle this command by doing something like:

saveImageAs

	| name |
	name := self bodyAt: 'name'.
	Smalltalk saveAs: name

Considering the definition given at , the command sent for processing should look like this:

see Command definitions
Example 1: Pharo image cleanup
Example 2: saving image with a different name