jhass changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.28.0 | Fund Crystal's development: http://is.gd/X7PRtI | GH: https://github.com/crystal-lang/crystal | Docs: http://crystal-lang.org/docs/ | API: http://crystal-lang.org/api/ | Gitter: https://gitter.im/crystal-lang/crystal
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
<alex``> how to declare the type of a variable?
laaron has joined #crystal-lang
<alex``> I have foo_command = nil, by default, but can be a String
<FromGitter> <Blacksmoke16> `foo_command : String? = nil`
<FromGitter> <Blacksmoke16> would restrict the values you can set it to to string or nil
<alex``> I have this error
<alex``> modification_command can be nil or string
<alex``> I check `if modification_command`, before doing `modification_command % { ... }`
<alex``> why Crystal tells me: in src/batch.cr:92: undefined method '%' for Nil (compile-time type is (String | Nil))
<alex``> since I check with if, modification_command is never nil here
rohitpaulk has joined #crystal-lang
<FromGitter> <Blacksmoke16> change it to like `if command = modification_command`
<FromGitter> <Blacksmoke16> then reference command
<alex``> oh nice
rohitpaulk has quit [Ping timeout: 248 seconds]
chemist69 has quit [Ping timeout: 252 seconds]
chemist69 has joined #crystal-lang
gangstacat has quit [Quit: Ĝis!]
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
gangstacat has joined #crystal-lang
return0e has quit [Read error: Connection reset by peer]
return0e_ has joined #crystal-lang
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
laaron has joined #crystal-lang
alex`` has quit [Quit: WeeChat 2.4]
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
return0e has joined #crystal-lang
return0e_ has quit [Ping timeout: 268 seconds]
<FromGitter> <watzon> Just realized I haven't seen @oprypin in a while
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
laaron has joined #crystal-lang
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
<FromGitter> <girng> I miss him
<FromGitter> <bararchy> I just talked with him Yesterday here
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
laaron has joined #crystal-lang
return0e has quit [Read error: Connection reset by peer]
return0e has joined #crystal-lang
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Remote host closed the connection]
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
ashirase has quit [Ping timeout: 272 seconds]
ashirase has joined #crystal-lang
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
_whitelogger has joined #crystal-lang
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
laaron has joined #crystal-lang
_whitelogger has joined #crystal-lang
<FromGitter> <kingsleyh> @mwlang yes indeed :)
early has quit [Quit: Leaving]
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
laaron- has joined #crystal-lang
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
alex`` has joined #crystal-lang
laaron- has quit [Remote host closed the connection]
laaron has joined #crystal-lang
return0e has quit [Read error: Connection reset by peer]
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
return0e has joined #crystal-lang
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
laaron has joined #crystal-lang
DTZUZU2 is now known as DTZUZU
<FromGitter> <dscottboggs_gitlab> > change it to like `if command = modification_command` ⏎ > then reference command ⏎ ⏎ why is this required sometimes but not others? [https://gitter.im/crystal-lang/crystal?at=5cf3cf986fc5846bab4ca70d]
<FromGitter> <Blacksmoke16> :shrug:
alex`` has quit [Read error: Connection reset by peer]
<FromGitter> <dscottboggs_gitlab> https://carc.in/#/r/70wm
alex`` has joined #crystal-lang
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
<FromGitter> <j8r> that's not necessary if it's a variable
<FromGitter> <Blacksmoke16> but it is a variable in that example?
<FromGitter> <j8r> maybe it's a method
<FromGitter> <j8r> haven't looked at it
<FromGitter> <j8r> but in Crystal, methods and variables looks the same
<FromGitter> <j8r> https://carc.in/#/r/70wq
<FromGitter> <Blacksmoke16> dunno, hes deff setting it like `unchanged_command : String? = nil`
<FromGitter> <j8r> strange yes
<FromGitter> <j8r> It compiles if the OptionParser code is removed
<FromGitter> <j8r> reduced: https://carc.in/#/r/70ww
DTZUZU has quit [Quit: WeeChat 2.2]
<alex``> how to escape string?
<FromGitter> <j8r> a character you mean?
<alex``> The use case is to write a shell program to a file, similarly to bulk-rename of ranger file manager
<FromGitter> <j8r> doesn't exist in the stlib
<alex``> Do you think I should update the issue to present the use case?
<alex``> and if it’s not, how to emulate that function?
<FromGitter> <j8r> don't know
<FromGitter> <j8r> what do you want?
<FromGitter> <j8r> Maybe a shard exist for this, or you need to create one
<alex``> I read a list of files from stdin, edit with an editor, then {input} → {output} with a given command, `<command> %{1} %{2}`
<alex``> I want to write the commands in a file, present it to the user to execute it
<alex``> I use something like this
<alex``> command = `mv %{1} %{2}` (for example)
<alex``> command % { "1" => input, "2" => output }
<alex``> system(command)
<alex``> input and output need to be escaped
<FromGitter> <j8r> there is no magic function in the stdlib
<alex``> there is a function to escape strings?
<FromGitter> <j8r> you'll have to rely on yourself, or find/create a lib for
<alex``> with a given list of characters
<FromGitter> <j8r> this can be easily done
<alex``> what does string.inspect do?
<alex``> > Currently the string is shell-escaped by simply calling inspect.
<FromGitter> <j8r> this is for debugging
<FromGitter> <j8r> *mainly
<FromGitter> <j8r> good if it does the job for you :)
<alex``> I’m not sure xd
<alex``> I want it safe lol
<alex``> it sensible to batch rename files
<FromGitter> <j8r> shell safe, because there is also URL safe
<FromGitter> <j8r> that exists
return0e has quit [Ping timeout: 272 seconds]
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
return0e has joined #crystal-lang
laaron has joined #crystal-lang
DTZUZU has joined #crystal-lang
DTZUZU has quit [Quit: WeeChat 2.2]
DTZUZU has joined #crystal-lang
return0e has quit [Ping timeout: 272 seconds]
return0e has joined #crystal-lang
<FromGitter> <PlayLights_twitter> Hello guys, does anyone has an idea on why when I write to STDOUT it doesn't appear on docker logs?
<FromGitter> <Blacksmoke16> try doing a `STDOUT.flush1`1
moei has joined #crystal-lang
<FromGitter> <PlayLights_twitter> Im flushing after doing some writing like ⏎ ´´´ ⏎ @io << "Hello there" ⏎ @io.flush ⏎ ´´´ ... [https://gitter.im/crystal-lang/crystal?at=5cf3fd277c1dab468c8c0059]
<FromGitter> <PlayLights_twitter> Looks like that worked but `Unhandled exception in spawn: Closed stream (IO::Error)` came out
<FromGitter> <PlayLights_twitter> @thanks @Blacksmoke16
<FromGitter> <Blacksmoke16> gotta be sure to not close STDOUT
<FromGitter> <Blacksmoke16> if you're doing like `@io.close` somewhere
<FromGitter> <PlayLights_twitter> Interesting, it doesn't work, also the "puts" method doesn't print anything. 🤔 (I know it is running because it works)
<FromGitter> <Blacksmoke16> hm
<FromGitter> <PlayLights_twitter> @Blacksmoke16 Alright, looks like it could be an issue on Crystal 0.28.0 or on crystal 0.28.0 on docker hub
<FromGitter> <PlayLights_twitter> changing it to 0.27.2 everything is working fine
<FromGitter> <Blacksmoke16> try nightly
<FromGitter> <PlayLights_twitter> let's see
<FromGitter> <PlayLights_twitter> Getting this ´/usr/bin/crystal: 105: exec: /usr/bin/../lib/crystal/bin/crystal: not found´ Looks like I would need to compile crystal to use it?
<FromGitter> <Blacksmoke16> i noticed that too 😐
<FromGitter> <PlayLights_twitter> I see that too, so by now for some reason 0.28.0 is not printing to STDOUT or at least on docker, im not an expert on how it works so I can't say why
nathanj has quit [Quit: WeeChat 2.4]
<FromGitter> <PlayLights_twitter> Hello, I just sent a test with artillery.io to a web socket on kemal crystal and I got this ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ Im not sure what is the problem, some kind of problem between GC and OS [https://gitter.im/crystal-lang/crystal?at=5cf4278f702b7e5e761a93b8]
<FromGitter> <watzon> Is it possible to use libgen to generate bindings based on just a header file?
<FromGitter> <watzon> I'm trying, but it's saying that `.h` is an unsupported format, which makes sense because you can't compile a header file
<FromGitter> <watzon> I figured that part out, but now for some reason it's saying there's nothing to import from my header
<FromGitter> <watzon> Figured that out too. I thought the `prefixes` option was something different
<FromGitter> <watzon> Gahhh linking issues
moei has quit [Quit: Leaving...]
<FromGitter> <watzon> So here's the problem, let's see if anyone knows if this is possible. I have a c header file, webview.h (https://github.com/zserge/webview/blob/master/webview.h), which I'm trying to link. According to the instructions here (https://github.com/zserge/webview) you should be able to just include the header in a c file and use it, which I was able to confirm is working on my system.
<FromGitter> <watzon> I guess I'm just wondering how you can link a header file. I've tried everything I can think of.
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/70yj hmm
<FromGitter> <watzon> Am I going to have to write a wrapper for it in C?
<FromGitter> <watzon> @Blacksmoke16 I've gotten that before too
<FromGitter> <Blacksmoke16> remember the solution? :p
<FromGitter> <Blacksmoke16> just define then as `self.new` maybe?
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5cf45a2a65392c3b60ac207f]
<FromGitter> <Blacksmoke16> reduced
<FromGitter> <Blacksmoke16> `self.class.new` worked
<FromGitter> <Blacksmoke16> makes sense i guess
<FromGitter> <watzon> Yeah you can do that or just call `Foo.new