Skip to content
This repository has been archived by the owner on Jun 5, 2023. It is now read-only.

Make bin-script on-par with scala script #38

Closed
felixmulder opened this issue Sep 20, 2016 · 3 comments
Closed

Make bin-script on-par with scala script #38

felixmulder opened this issue Sep 20, 2016 · 3 comments

Comments

@felixmulder
Copy link

The scala script has a larger amount of sophistication than our current ./bin/dotr. Help text from scala script:

Usage: scala <options> [<script|class|object|jar> <arguments>]
   or  scala -help

All options to scalac (see scalac -help) are also allowed.

The first given argument other than options to scala designates
what to run.  Runnable targets are:

  - a file containing scala source
  - the name of a compiled class
  - a runnable jar file with a valid Main-Class attribute
  - or if no argument is given, the repl (interactive shell) is started

Options to scala which reach the java runtime:

 -Dname=prop  passed directly to java to set system properties
 -J<arg>      -J is stripped and <arg> passed to java as-is
 -nobootcp    do not put the scala jars on the boot classpath (slower)

Other startup options:

 -howtorun    what to run <script|object|jar|guess> (default: guess)
 -i <file>    preload <file> before starting the repl
 -e <string>  execute <string> as if entered in the repl
 -save        save the compiled script in a jar for future use
 -nc          no compilation daemon: do not use the fsc offline compiler

A file argument will be run as a scala script unless it contains only
self-contained compilation units (classes and objects) and exactly one
runnable main method.  In that case the file will be compiled and the
main method invoked.  This provides a bridge between scripts and standard
scala source.

When running a script or using -e, an already running compilation daemon
(fsc) is used, or a new one started on demand.  The -nc option can be
used to prevent this.

With that being said what we'd actually like to do is to have main command with sub commands - think git or go.

E.g. to compile you'd go:

$ ./bin/dotc compile <ARGS>

to launch an interactive repl you'd say:

$ ./bin/dotc repl
@felixmulder felixmulder changed the title Make ./bin/dotr on-par with scala script Make bin-script on-par with scala script Oct 11, 2016
@Varunram
Copy link

@felixmulder Assuming this is still a novice issue, is the end goal to combine both dotc and dotr into simply dotc? I would love it if you'd provide more insight into this. Thanks!

@felixmulder
Copy link
Author

It sort of is, but it's not really a pressing issue. We've decided to do the first releases without scripts.

That being said, the scripts are in need of some form of update. But, we're still considering how to package things. I'd hold off on this for a little while..

@liufengyun liufengyun transferred this issue from scala/scala3 Jun 3, 2019
@SethTisue
Copy link

SethTisue commented Oct 19, 2022

there is a SIP in this area: scala/improvement-proposals#46

even before the SIP is approved or not, scala-cli is already available and works well: https://scala-cli.virtuslab.org/scripting

@lampepfl lampepfl locked and limited conversation to collaborators Jun 5, 2023
@ckipp01 ckipp01 converted this issue into a discussion Jun 5, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants