Pārlūkot izejas kodu

AmberCli now displays Browser with AmberCli package:
Gruntfile.js modified 'amber_cli' target to use 'amber_cli' namespace
cli/index.html requirejs config paths for module 'amber_cli'
recompile with grunt amberc:amber_cli

Thomas Rake 10 gadi atpakaļ
vecāks
revīzija
ac26efad40
5 mainītis faili ar 41 papildinājumiem un 27 dzēšanām
  1. 2 1
      Gruntfile.js
  2. 18 5
      cli/index.html
  3. 2 2
      cli/js/AmberCli.js
  4. 3 3
      cli/js/amber-cli.js
  5. 16 16
      cli/st/AmberCli.st

+ 2 - 1
Gruntfile.js

@@ -98,7 +98,8 @@ module.exports = function(grunt) {
             'Compiler-IR', 'Compiler-Inlining', 'Compiler-Semantic', 'Compiler-Interpreter', '@parser'
             'Compiler-IR', 'Compiler-Inlining', 'Compiler-Semantic', 'Compiler-Interpreter', '@parser'
         ],
         ],
         main_class: 'AmberCli',
         main_class: 'AmberCli',
-        output_name: 'amber-cli'
+        output_name: 'amber-cli',
+        amd_namespace: 'amber_cli'
       }
       }
     },
     },
 
 

+ 18 - 5
cli/index.html

@@ -5,15 +5,28 @@
     <title>Amber Smalltalk</title> 
     <title>Amber Smalltalk</title> 
     <meta http-equiv="content-type" content="text/html; charset=utf-8" /> 
     <meta http-equiv="content-type" content="text/html; charset=utf-8" /> 
     <meta name="author" content="Nicolas Petton" /> 
     <meta name="author" content="Nicolas Petton" /> 
-    <script type='text/javascript' src='../support/amber.js'></script>
+    <script type='text/javascript' src='../support/requirejs/require.min.js'></script>
+    <script src='../support/amber.js'></script>
+
   </head> 
   </head> 
 
 
   <body> 
   <body> 
     <script type='text/javascript'>
     <script type='text/javascript'>
-      loadAmber({
-        files: ['AmberCli.js'],
-        prefix: 'cli/js',
-        ready: function() {smalltalk.Browser._open()}})
+    require.config({
+        paths: {
+            'amber_cli': 'js',
+            'amber_cli/_source': 'st'
+        }
+    });
+    require(
+        ["amber/devel",
+            "amber_cli/AmberCli" ],
+        function (smalltalk) {
+            smalltalk.defaultAMDNamespace = 'amber_cli';
+            smalltalk.initialize();
+            smalltalk.Browser._openOn_(smalltalk.AmberCli);
+        }
+    );
     </script> 
     </script> 
   </body> 
   </body> 
 </html> 
 </html> 

+ 2 - 2
cli/js/AmberCli.js

@@ -1,6 +1,6 @@
-define("amber_core/AmberCli", ["amber_vm/smalltalk", "amber_vm/nil", "amber_vm/_st", "amber_core/Kernel-Objects"], function(smalltalk,nil,_st){
+define("amber_cli/AmberCli", ["amber_vm/smalltalk", "amber_vm/nil", "amber_vm/_st", "amber_core/Kernel-Objects"], function(smalltalk,nil,_st){
 smalltalk.addPackage('AmberCli');
 smalltalk.addPackage('AmberCli');
-smalltalk.packages["AmberCli"].transport = {"type":"amd","amdNamespace":"amber_core"};
+smalltalk.packages["AmberCli"].transport = {"type":"amd","amdNamespace":"amber_cli"};
 
 
 smalltalk.addClass('AmberCli', smalltalk.Object, [], 'AmberCli');
 smalltalk.addClass('AmberCli', smalltalk.Object, [], 'AmberCli');
 smalltalk.AmberCli.comment="I am the Amber CLI (CommandLine Interface) tool which runs on Node.js.\x0a\x0aMy responsibility is to start different Amber programs like the FileServer or the Repl.\x0aWhich program to start is determined by the first commandline parameters passed to the AmberCli executable.\x0aUse `help` to get a list of all available options.\x0aAny further commandline parameters are passed to the specific program.\x0a\x0a## Commands\x0a\x0aNew commands can be added by creating a class side method in the `commands` protocol which takes one parameter.\x0aThis parameter is an array of all commandline options + values passed on to the program.\x0aAny `camelCaseCommand` is transformed into a commandline parameter of the form `camel-case-command` and vice versa.";
 smalltalk.AmberCli.comment="I am the Amber CLI (CommandLine Interface) tool which runs on Node.js.\x0a\x0aMy responsibility is to start different Amber programs like the FileServer or the Repl.\x0aWhich program to start is determined by the first commandline parameters passed to the AmberCli executable.\x0aUse `help` to get a list of all available options.\x0aAny further commandline parameters are passed to the specific program.\x0a\x0a## Commands\x0a\x0aNew commands can be added by creating a class side method in the `commands` protocol which takes one parameter.\x0aThis parameter is an array of all commandline options + values passed on to the program.\x0aAny `camelCaseCommand` is transformed into a commandline parameter of the form `camel-case-command` and vice versa.";

+ 3 - 3
cli/js/amber-cli.js

@@ -35617,9 +35617,9 @@ smalltalk.parser = (function(){
   return result;
   return result;
 })();
 })();
 });
 });
-define("amber_core/AmberCli", ["amber_vm/smalltalk", "amber_vm/nil", "amber_vm/_st", "amber_core/Kernel-Objects"], function(smalltalk,nil,_st){
+define("amber_cli/AmberCli", ["amber_vm/smalltalk", "amber_vm/nil", "amber_vm/_st", "amber_core/Kernel-Objects"], function(smalltalk,nil,_st){
 smalltalk.addPackage('AmberCli');
 smalltalk.addPackage('AmberCli');
-smalltalk.packages["AmberCli"].transport = {"type":"amd","amdNamespace":"amber_core"};
+smalltalk.packages["AmberCli"].transport = {"type":"amd","amdNamespace":"amber_cli"};
 
 
 smalltalk.addClass('AmberCli', smalltalk.Object, [], 'AmberCli');
 smalltalk.addClass('AmberCli', smalltalk.Object, [], 'AmberCli');
 smalltalk.AmberCli.comment="I am the Amber CLI (CommandLine Interface) tool which runs on Node.js.\x0a\x0aMy responsibility is to start different Amber programs like the FileServer or the Repl.\x0aWhich program to start is determined by the first commandline parameters passed to the AmberCli executable.\x0aUse `help` to get a list of all available options.\x0aAny further commandline parameters are passed to the specific program.\x0a\x0a## Commands\x0a\x0aNew commands can be added by creating a class side method in the `commands` protocol which takes one parameter.\x0aThis parameter is an array of all commandline options + values passed on to the program.\x0aAny `camelCaseCommand` is transformed into a commandline parameter of the form `camel-case-command` and vice versa.";
 smalltalk.AmberCli.comment="I am the Amber CLI (CommandLine Interface) tool which runs on Node.js.\x0a\x0aMy responsibility is to start different Amber programs like the FileServer or the Repl.\x0aWhich program to start is determined by the first commandline parameters passed to the AmberCli executable.\x0aUse `help` to get a list of all available options.\x0aAny further commandline parameters are passed to the specific program.\x0a\x0a## Commands\x0a\x0aNew commands can be added by creating a class side method in the `commands` protocol which takes one parameter.\x0aThis parameter is an array of all commandline options + values passed on to the program.\x0aAny `camelCaseCommand` is transformed into a commandline parameter of the form `camel-case-command` and vice versa.";
@@ -37389,7 +37389,7 @@ smalltalk.Repl.klass);
 
 
 });
 });
 
 
-define("amber_vm/_init", ["amber_vm/smalltalk","amber_vm/smalltalk","amber_vm/nil","amber_vm/_st","amber_core/Kernel-Objects","amber_core/Kernel-Classes","amber_core/Kernel-Methods","amber_core/Kernel-Collections","amber_core/Kernel-Infrastructure","amber_core/Kernel-Exceptions","amber_core/Kernel-Transcript","amber_core/Kernel-Announcements","amber_core/Compiler-Exceptions","amber_core/Compiler-Core","amber_core/Compiler-AST","amber_core/Compiler-IR","amber_core/Compiler-Inlining","amber_core/Compiler-Semantic","amber_core/Compiler-Interpreter","amber_vm/parser","amber_core/AmberCli"], function (smalltalk) {
+define("amber_vm/_init", ["amber_vm/smalltalk","amber_vm/smalltalk","amber_vm/nil","amber_vm/_st","amber_core/Kernel-Objects","amber_core/Kernel-Classes","amber_core/Kernel-Methods","amber_core/Kernel-Collections","amber_core/Kernel-Infrastructure","amber_core/Kernel-Exceptions","amber_core/Kernel-Transcript","amber_core/Kernel-Announcements","amber_core/Compiler-Exceptions","amber_core/Compiler-Core","amber_core/Compiler-AST","amber_core/Compiler-IR","amber_core/Compiler-Inlining","amber_core/Compiler-Semantic","amber_core/Compiler-Interpreter","amber_vm/parser","amber_cli/AmberCli"], function (smalltalk) {
 smalltalk.initialize();
 smalltalk.initialize();
 smalltalk.AmberCli._main();
 smalltalk.AmberCli._main();
 });
 });

+ 16 - 16
cli/st/AmberCli.st

@@ -903,12 +903,12 @@ My runtime requirement is a functional Node.js executable with working Readline
 
 
 !Repl methodsFor: 'accessing'!
 !Repl methodsFor: 'accessing'!
 
 
-prompt
-	^'amber >> '
-!
-
 commands
 commands
 	^ commands
 	^ commands
+!
+
+prompt
+	^'amber >> '
 ! !
 ! !
 
 
 !Repl methodsFor: 'actions'!
 !Repl methodsFor: 'actions'!
@@ -955,14 +955,14 @@ initialize
 	self setupCommands
 	self setupCommands
 !
 !
 
 
-setupHotkeys
-	process stdin on: 'keypress' do: [:s :key | key ifNotNil: [self onKeyPress: key]].
-!
-
 setupCommands
 setupCommands
 	commands := Dictionary from: {
 	commands := Dictionary from: {
 		{':q'} -> [process exit].
 		{':q'} -> [process exit].
 		{''} -> [interface prompt]}
 		{''} -> [interface prompt]}
+!
+
+setupHotkeys
+	process stdin on: 'keypress' do: [:s :key | key ifNotNil: [self onKeyPress: key]].
 ! !
 ! !
 
 
 !Repl methodsFor: 'private'!
 !Repl methodsFor: 'private'!
@@ -987,6 +987,14 @@ assignNewVariable: buffer do: aBlock
 		aBlock value: varName value: value]
 		aBlock value: varName value: value]
 !
 !
 
 
+clearScreen
+	| esc cls |
+	esc := String fromCharCode: 27.
+	cls := esc, '[2J', esc, '[0;0f'.
+	process stdout write: cls.
+	interface prompt
+!
+
 encapsulateVariable: aString withValue: anObject in: aClass
 encapsulateVariable: aString withValue: anObject in: aClass
 	"Add getter and setter for given variable to session."
 	"Add getter and setter for given variable to session."
 	| compiler |
 	| compiler |
@@ -1033,14 +1041,6 @@ onKeyPress: key
 		ifTrue: [self clearScreen]
 		ifTrue: [self clearScreen]
 !
 !
 
 
-clearScreen
-	| esc cls |
-	esc := String fromCharCode: 27.
-	cls := esc, '[2J', esc, '[0;0f'.
-	process stdout write: cls.
-	interface prompt
-!
-
 parseAssignment: aString do: aBlock
 parseAssignment: aString do: aBlock
 	"Assigns a new variable if the given string is an assignment expression. Calls the given block with name and value.
 	"Assigns a new variable if the given string is an assignment expression. Calls the given block with name and value.
 	 If the string is not one no variable will be assigned and the block will be called with nil for both arguments."
 	 If the string is not one no variable will be assigned and the block will be called with nil for both arguments."