পৃষ্ঠাসমূহ

Search Your Article

CS

 

Welcome to GoogleDG – your one-stop destination for free learning resources, guides, and digital tools.

At GoogleDG, we believe that knowledge should be accessible to everyone. Our mission is to provide readers with valuable ebooks, tutorials, and tech-related content that makes learning easier, faster, and more enjoyable.

What We Offer:

  • 📘 Free & Helpful Ebooks – covering education, technology, self-development, and more.

  • 💻 Step-by-Step Tutorials – practical guides on digital tools, apps, and software.

  • 🌐 Tech Updates & Tips – simplified information to keep you informed in the fast-changing digital world.

  • 🎯 Learning Support – resources designed to support students, professionals, and lifelong learners.

    Latest world News 

     

Our Vision

To create a digital knowledge hub where anyone, from beginners to advanced learners, can find trustworthy resources and grow their skills.

Why Choose Us?

✔ Simple explanations of complex topics
✔ 100% free access to resources
✔ Regularly updated content
✔ A community that values knowledge sharing

We are continuously working to expand our content library and provide readers with the most useful and relevant digital learning materials.

📩 If you’d like to connect, share feedback, or suggest topics, feel free to reach us through the Contact page.

Pageviews

Thursday, February 2, 2017

Groovy - Command Line

The Groovy shell known as groovysh can be easily used to evaluate groovy expressions, define classes and run simple programs. The command line shell gets installed when Groovy is installed.
Following are the command line options available in Groovy −

Command line parameter Full Name Details
-C --color[=FLAG] Enable or disable use of ANSI colors
-D --define=NAME=VALUE Define a system property
-T --terminal=TYPE Specify the terminal TYPE to use
-V --version Display the version
-classpath
Specify where to find the class files – must be the first argument
-cp --classpath Aliases for '-classpath'
-d --debug --debug Enable debug output
-e --evaluate=arg Evaluate option fist when starting interactive session
-h --help Display this help message
-q --quiet Suppress superfluous output
-v --verbose Enable verbose output
The following snapshot shows a simple example of an expression being executed in the Groovy shell. In the following example we are just printing “Hello World” in the groovy shell.
Groovy Shell

Classes and Functions

It is very easy to define a class in the command prompt, create a new object and invoke a method on the class. The following example shows how this can be implemented. In the following example, we are creating a simple Student class with a simple method. In the command prompt itself, we are creating an object of the class and calling the Display method.
Create Std Class It is very easy to define a method in the command prompt and invoke the method. Note that the method is defined using the def type. Also note that we have included a parameter called name which then gets substituted with the actual value when the Display method is called. The following example shows how this can be implemented.
prompt and invoke command

Commands

The shell has a number of different commands, which provide rich access to the shell’s environment. Following is the list of them and what they do.
Command Command Description
:help (:h ) Display this help message
? (:? ) Alias to: :help
:exit (:x ) Exit the shell
:quit (:q ) Alias to: :exit
import (:i ) Import a class into the namespace
:display (:d ) Display the current buffer
:clear (:c ) Clear the buffer and reset the prompt counter
:show (:S ) Show variables, classes or imports
:inspect (:n ) Inspect a variable or the last result with the GUI object browser
:purge (:p ) Purge variables, classes, imports or preferences
:edit (:e ) Edit the current buffer
:load (:l ) Load a file or URL into the buffer
. (:. ) Alias to: :load
.save (:s ) Save the current buffer to a file
.record (:r ) Record the current session to a file
:alias (:a ) Create an alias
:set (:= ) Set (or list) preferences
:register (:rc) Registers a new command with the shell
:doc (:D ) Opens a browser window displaying the doc for the argument
:history (:H ) Display, manage and recall edit-line history

No comments:

Post a Comment