-
Notifications
You must be signed in to change notification settings - Fork 493
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
Add stdinIsATTY template function #1111
Conversation
Sure, let me try. |
Ah, you need the |
I realized it, sorry. I'm trying to figure out what to do to not have a stdin, to check. |
Well, it doesn't work in the following scenario: $ docker run -v c:\Users\felip\Downloads:c:\Downloads mcr.microsoft.com/windows:20H2 C:\Downloads\chezmoi.exe execute-template --init '{{ stdinIsATTY }}'
true |
But surprisingly, it works like a charm when using a > cat .\.chezmoi.toml.tmpl
{{ $email := "" }}
{{ if stdinIsATTY }}
{{ $email = promptString "email" }}
{{ else }}
{{ $email = "[email protected]" }}
{{ end }}
[data]
email = "{{ $email }}"
> docker run -v c:\Users\felip\Downloads:c:\Downloads mcr.microsoft.com/windows:20H2 powershell -command 'C:\Downloads\chezmoi.exe init --verbose --source C:\Downloads; C:\Downloads\chezmoi.exe data --verbose --source C:\Downloads'
{
"chezmoi": {
"arch": "amd64",
"fqdnHostname": "7d2ad3306736",
"homeDir": "C:\\Users\\ContainerAdministrator",
"homedir": "C:\\Users\\ContainerAdministrator",
"hostname": "7d2ad3306736",
"kernel": null,
"os": "windows",
"osRelease": {},
"sourceDir": "C:/Downloads",
"username": "User Manager\\ContainerAdministrator",
"version": {
"builtBy": "goreleaser",
"commit": "56485778b5334f3aa05b5d12abff0db00cc8cb2b",
"date": "2021-03-28T18:30:09Z",
"version": "v2.0.4-SNAPSHOT-5648577"
}
},
"email": "[email protected]"
}
> docker run -ti -v c:\Users\felip\Downloads:c:\Downloads mcr.microsoft.com/windows:20H2 powershell -command 'C:\Downloads\chezmoi.exe init --verbose --source C:\Downloads; C:\Downloads\chezmoi.exe data --verbose --source C:\Downloads'
email? teste
{
"chezmoi": {
"arch": "amd64",
"fqdnHostname": "9e5d16128b04",
"homeDir": "C:\\Users\\ContainerAdministrator",
"homedir": "C:\\Users\\ContainerAdministrator",
"hostname": "9e5d16128b04",
"kernel": null,
"os": "windows",
"osRelease": {},
"sourceDir": "C:/Downloads",
"username": "User Manager\\ContainerAdministrator",
"version": {
"builtBy": "goreleaser",
"commit": "56485778b5334f3aa05b5d12abff0db00cc8cb2b",
"date": "2021-03-28T18:30:09Z",
"version": "v2.0.4-SNAPSHOT-5648577"
}
},
"email": "teste"
} Nonetheless, when using only > docker run -t -v c:\Users\felip\Downloads:c:\Downloads mcr.microsoft.com/windows:20H2 powershell -command 'C:\Downloads\chezmoi.exe init --verbose --source C:\Downloads; C:\Downloads\chezmoi.exe data --verbose --source C:\Downloads'
email? |
If you want me to test anything, feel free to ask me. It took me a while to setup this Windows containers environment, hahaha. |
Thanks so much for the testing @felipecrs :) I had no idea that Windows container environments existed. This is potentially really interesting for CI. |
Yeah... the only caveat is that you need a Windows host, and the Windows docker image is around 6GB to pull. There are smaller ones, such as the Windows Nano Server (150MB), but sadly |
Ah, thanks. It also looks like you need Windows 10 Pro to run Windows images, and I only have Windows 10 Home on my laptop. |
Fixes #1109.
@felipecrs would you be able to test this? I'm not sure how it behaves on Windows.