Can't pipe into headless prompt
Whenever I try to pipe into Briar's registration prompt, I get this output:
No account found. Let's create one!
Nickname: Password: Exception in thread "main" java.lang.RuntimeException: EOF
at com.github.ajalt.clikt.output.NonInteractiveCliktConsole.promptForLine(CliktConsole.kt:63)
at com.github.ajalt.clikt.output.TermUi.prompt(TermUi.kt:94)
at com.github.ajalt.clikt.output.TermUi.prompt$default(TermUi.kt:86)
at org.briarproject.briar.headless.BriarServiceImpl.createAccount(BriarService.kt:60)
at org.briarproject.briar.headless.BriarServiceImpl.start(BriarService.kt:33)
at org.briarproject.briar.headless.Router.start$briar_headless(Router.kt:45)
at org.briarproject.briar.headless.Main.run(Main.kt:78)
at com.github.ajalt.clikt.parsers.Parser.parse(Parser.kt:112)
at com.github.ajalt.clikt.parsers.Parser.parse(Parser.kt:19)
at com.github.ajalt.clikt.core.CliktCommand.parse(CliktCommand.kt:166)
at com.github.ajalt.clikt.core.CliktCommand.parse$default(CliktCommand.kt:164)
at com.github.ajalt.clikt.core.CliktCommand.main(CliktCommand.kt:181)
at com.github.ajalt.clikt.core.CliktCommand.main(CliktCommand.kt:200)
at org.briarproject.briar.headless.MainKt.main(Main.kt:115)
This is how I tried it:
Python
p = Popen(['java', '-jar', self.headless_jar, '-v'],
stdin=PIPE, universal_newlines=True)
p.communicate(credentials[0] + '\n' + credentials[1] +
'\n' + credentials[1] + '\n')
Bash
echo "nico
password
password
" | java -jar briar-headless.jar
Upstream had an issue called NonInteractiveCliktConsole only reads in the first line from an input file which sounds like the origin of this problem. It was fixed in newer versions (1.6.0). Before that version, it failed like this:
INFO: No database key in backup file
No account found. Let's create one!
Nickname: Password: Usage: briar-headless [OPTIONS]
Error: Could not get account information. Is STDIN connected?
In the meantime, version 1.7.0 was released but it doesn't change anything regarding this problem. I have built a version of briar-headless with 1.7.0 and tested it both in bash and python and get the same exception like with 1.6.0.
We should investigate why we get this exception when upstream claims to now support multi-line pipes.
On IRC we discussed to allow environment variables as an alternative for "scripted use" of the api.
Related:
- Lines of code producing exception in clikt
- Fixed issue called Make possible to use arbitrary input/output stream
- Lines of code in briar-gtk's current code
- Lines of code of prompt in briar-headless
- Commit Update clikt to 1.7.0