Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Users.Root constant added. #113

Merged
merged 1 commit into from
Dec 20, 2013
Merged

Conversation

kardapoltsev
Copy link
Member

Also fix string interpolation in another PR, added chdir command to start-stop-daemon.

@@ -37,7 +37,7 @@ RUN_CMD="-cp ${{app_classpath}} ${{app_main_class}} $RUN_OPTS"

start_daemon() {
log_daemon_msg "Starting" "${{app_name}}"
start-stop-daemon --background --chuid "$DAEMON_USER" --make-pidfile --pidfile "$PIDFILE" --exec "$JAVA_CMD" --start -- $RUN_CMD
start-stop-daemon --background --chdir ${{chdir}} --chuid "$DAEMON_USER" --make-pidfile --pidfile "$PIDFILE" --exec "$JAVA_CMD" --start -- $RUN_CMD
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is sweet. The default logging configuration files always rely on this, what makes uninstalling rather messy.

@jsuereth
Copy link
Member

Looks great! Thanks much for the fixes.

jsuereth added a commit that referenced this pull request Dec 20, 2013
@jsuereth jsuereth merged commit 185e167 into sbt:master Dec 20, 2013
@kardapoltsev
Copy link
Member Author

What do you think about smth like this:

object Path {
  import RichString.toRichString
  val Root = "/" 
  val Usr = "usr"
  val Share = "share"
}

object RichString {
  implicit def toRichString(str: String): RichString = new RichString(str)
}

class RichString(self: String) {
  def / (other: String) = if(self.endsWith("/")) self + other else self + "/" + other
}

And we cound write

val instalLocation = Root / Usr / Share

@jsuereth
Copy link
Member

Well, Path/RichString already exist as types, so it's a bit confusing. I've also learned to be careful around implicits like this. Being too clever can cause issues.

What you probably want, for safety,

case class PathString(path: String) {
   def /(other: PathString): PathString = 
      if(path.endsWith("/")) PathString(path + other.path)
      else PathString(path + "/" + other.path)

   def asString: String = path
}
object PathString {
  implicit def convertToString(p: PathString): String = p.path
  val Root = "/"
  val Usr = "usr"
  val Share = "share"
}

Now you can still write:

val installLocation: String = Root / Usr / Share

However, if you drop the type annotation it gets odd, you'd want to write:

val installLocation = (Root / Usr / Share).asString

Or some other kind of DSLery hacks.

@kardapoltsev
Copy link
Member Author

Thanks a lot for comments!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants