Skip to content

Commit

Permalink
Update ancient README example for cats usage
Browse files Browse the repository at this point in the history
  • Loading branch information
japgolly committed Sep 9, 2022
1 parent d5aa755 commit a4f7872
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ then use (nest) it in some higher-level config.
For example, this Scala code...

```scala
import cats.implicits._
import cats.syntax.apply._
import japgolly.clearconfig._
import java.net.{URI, URL}
import redis.clients.jedis.JedisPoolConfig
Expand All @@ -226,20 +226,20 @@ case class PostgresConfig(url: URL, credential: Credential, schema: Option[Strin

object PostgresConfig {
def config: ConfigDef[PostgresConfig] =
( ConfigDef.need[URL]("url") |@|
Credential.config |@|
ConfigDef.get[String]("schema")
) (apply)
( ConfigDef.need[URL]("url"),
Credential.config,
ConfigDef.get[String]("schema"),
).mapN(apply)
.withPrefix("postgres.")
}

case class Credential(username: String, password: String)

object Credential {
def config: ConfigDef[Credential] =
( ConfigDef.need[String]("username") |@|
ConfigDef.need[String]("password")
) (apply)
( ConfigDef.need[String]("username"),
ConfigDef.need[String]("password"),
).mapN(apply)
}

case class RedisConfig(uri: URI, credential: Credential, configurePool: JedisPoolConfig => Unit)
Expand Down Expand Up @@ -270,10 +270,10 @@ object RedisConfig {
)

def config: ConfigDef[RedisConfig] =
( ConfigDef.need[URI]("uri") |@|
Credential.config |@|
poolConfig.withPrefix("pool.")
)(apply)
( ConfigDef.need[URI]("uri"),
Credential.config,
poolConfig.withPrefix("pool."),
).mapN(apply)
.withPrefix("redis.")
}

Expand Down

0 comments on commit a4f7872

Please sign in to comment.