All Downloads are FREE. Search and download functionalities are using the official Maven repository.

scsh.getp.sc Maven / Gradle / Ivy

There is a newer version: 0.5.0
Show newest version

/*
	@Begin
		Display System properties
	Syntax
		getp  Display specified system property's value
		getp all Display all system proeprties
	@End
 */

import java.util.Properties

import com.thing2x.smqd.net.telnet.ScShell

import scala.collection.JavaConverters._

val args: Array[String] = $args

def printkv(k: String, v: String) = {
  var r = v
  r = r.replaceAll("\\n", "\\\\n")
  r = r.replaceAll("\\r", "\\\\r")
  println(s"$k = $r")
}

if (args.length != 2) {
  println("Usage: getp  | all")
}
else {
  val param = args(1)

  if ("all".equalsIgnoreCase(param)) {
    val prop: Properties = System.getProperties
    val arr: Seq[String] = prop.propertyNames().asScala.map(_.toString).toSeq.sorted

    //println(a)
    arr.foreach { k =>
      printkv(k, System.getProperty(k, ""))
    }
  }
  else {
    printkv(param, System.getProperty(param, ""))
  }
}





© 2015 - 2024 Weber Informatics LLC | Privacy Policy