Difference between revisions of "ChucK/Dev/Shell/doc"

From CSWiki
Jump to: navigation, search
(Command Summary)
(Inline Coding)
Line 49: Line 49:
  
 
== Inline Coding ==
 
== Inline Coding ==
 +
* <code>{ [code] }</code> adds <code>code</code> to the current VM
 +
** A <code>{ }</code> block can be stretched out over a number of lines
 +
** if so, the shell prompt will change to <code>code</code> and will also print the current scope level of the code entry.  Also, the code entry will be considered complete when the shell finds a matching brace for the first opening brace
 +
** If an alphannumeric text string is supplied after the final brace, the code will be saved within the shell and will be associated with that particular name.  Non-CR/LF whitespace may separate the brace and the code name. 
 +
*** example: <code>{ 0 => int i; } foo</code> will be saved as 'foo'
 +
** (potential advanced feature) specifying an arbitrary alphanumeric context name after the keyword <code>context</code> will apply the state context of that name to any code segment which opens on that line. 
 +
*** example: <code>context bar { 0 => int i; } </code> will apply context 'bar' to the following code
 +
*** if a context doesn't exist, it will be created using the state of the subsequent code entry
 +
*** a context is essentially a scope.  by executing two segments of code in a single context, they will have access to the same top-scope variables
 +
*** if no context is specified, then no new context is created and no special context is used
 +
* <code>code list [code_name]</code>
 +
* <code>code print [code_name]</code>
 +
* <code>code save ''code_name''</code> saves last code entry as code_name
 +
* <code>code delete ''code_name''</code>
 +
* <code>code add ''code_name'' </code> adds code_name to current VM
 +
* <code>code write ''code_name'' ''file''</code> writes code_name to file
 +
* <code>code read ''code_name'' ''file''</code> reads code in file to code_name
  
 
== Tutorial 1==  
 
== Tutorial 1==  
  
 
== Tutorial 2 ==
 
== Tutorial 2 ==

Revision as of 15:25, 2 March 2006

Introduction

The ChucK shell provides a simple, built-in way to add and modify programs on-the-fly and to manage ChucK sessions.

Command Line Options

--shell

Opens ChucK shell and starts the virtual machine.

--empty

Opens a ChucK shell without a virtual machine.

Command Summary

  • shell commands
  • Shred Management
    • add [files] or + [files]
      • adds [files] to current VM and prints out a shred reference number for each file
    • remove [ids] or - [ids]
    • removeall
    • replace id filename [id filename]...
    • -- (remove shred with highest id)
    • status or ^
  • Shell Management
    • ls (like unix ls)
    • alias and unalias (simple substitution-based, bash-like command aliases)
    • shreds list all shreds on the current VM
    • pwd
    • cd (change directory, also change current dir for chuck so paths are consistent)
    • close close down shell, keep process VM running
    • exit exit everything
  • Virtual Machine Management
    • vm attach [hostname[:port]] or vm @ [hostname[:port]] attempts to attach to a ChucK VM running on hostname:port. The default port is 8888. If no hostname or port is specified, the shell attempts to attach to the in-process VM
      • prints a success message and the VM reference number for each successful attachment; prints a failure message for each failed attachment
    • vm + or vm add
      • saves the current VM for later use
    • vm - [vm_reference] or vm remove [vm_reference]
      • removes specified VM--it is no longer on the VM list
    • vm = [vm_reference] or vm swap [vm_reference]
    • vms or vm list
      • lists all VMs plus the current VM
    • vm @+ hostname:port adds and attaches the specified VM
    • kill kills the current vm--shuts down the shell too if current_vm is the process vm

Inline Coding

  • { [code] } adds code to the current VM
    • A { } block can be stretched out over a number of lines
    • if so, the shell prompt will change to code and will also print the current scope level of the code entry. Also, the code entry will be considered complete when the shell finds a matching brace for the first opening brace
    • If an alphannumeric text string is supplied after the final brace, the code will be saved within the shell and will be associated with that particular name. Non-CR/LF whitespace may separate the brace and the code name.
      • example: { 0 => int i; } foo will be saved as 'foo'
    • (potential advanced feature) specifying an arbitrary alphanumeric context name after the keyword context will apply the state context of that name to any code segment which opens on that line.
      • example: context bar { 0 => int i; } will apply context 'bar' to the following code
      • if a context doesn't exist, it will be created using the state of the subsequent code entry
      • a context is essentially a scope. by executing two segments of code in a single context, they will have access to the same top-scope variables
      • if no context is specified, then no new context is created and no special context is used
  • code list [code_name]
  • code print [code_name]
  • code save code_name saves last code entry as code_name
  • code delete code_name
  • code add code_name adds code_name to current VM
  • code write code_name file writes code_name to file
  • code read code_name file reads code in file to code_name

Tutorial 1

Tutorial 2