Single quotes configuration with deno fmt - format

That's the whole point of the question.
deno fmt always changing my single quotes to double quotes every time I format.
Specifically, when fmt is run on a statement like this:
console.log( 'Deno' );
the statement is changed to:
console.log("Deno");
The expected behavior is to continue using single quotes by default.
Is there any configuration of fmt options?

You can now change the default behaviour of deno fmt by creating a deno.json file:
{
"fmt": {
"options": {
"singleQuote": true
}
}
}

Currently, there's no way to change default settings. Adding a config flag it's something that's being worked on, you can follow this issue

Related

Export array of JSON objects as environment variable

How can I export an environment variable like this?
USERS=[{name:a,surname:b,age:c},{name:d,surname:e,age:f}]
What I've tried so far unsuccessfully
[{"name":"a","surname":"b","age":"c"},{"name":"d","surname":"e","age":"f"}]
[{'name':'a','surname':'b','age':'c'},{'name':'d','surname':'e','age':'f'}]
[{\'name\':\'a\',\'surname\':\'b\',\'age\':\'c\'},{\'name\':\'d\',\'surname\':\'e\',\'age\':\'f\'}]
[{\"name\":\"a\",\"surname\":\"b\",\"age\":\"c\"},{\"name\":\"d\",\"surname\":\"e\",\"age\":\"f\"}]
"[{"name":"a","surname":"b","age":"c"},{"name":"d","surname":"e","age":"f"}]"
'[{"name":"a","surname":"b","age":"c"},{"name":"d","surname":"e","age":"f"}]'
'[{'name':'a','surname':'b','age':'c'},{'name':'d','surname':'e','age':'f'}]'
I know that with docker-compose and terraform this can easily be done but I have to define a single env var here
Something very important that I forgot to mentioned:
I want this variable to be read as a LIST since it's part of a configuration file. Not as a string. Since I want to map it to a User object.
User {
name,
surname,
age
}
Put it in quotes and use the export command to put it in the environment. Also, make it valid JSON by quoting all the strings
export USERS='[{"name":"a","surname":"b","age":10},{"name":"d","surname":"e","age":35}]'

How to pass bash variable as a string not array to a scala file

export str_opt="$(cat bi_sureyield_clicks_v.sql|tr '\n' ' ')"
sbt "run $str_opt"
I have this code in gitlab-ci.yml file. I want to do something when a sql file is commited in the repo.And since the sql file as \n init I truncate it and then send it to the scala project using sbt run but in the code I do something like
object printtest {
def main(args:Array[String]):Unit = {
println("HELLO WORLD SCALA" + args.length)
args.foreach{println}
}
}
and it shows length >1. It takes \n or space as a delimeter for a new string. How do I get it as a single string in scala so I can use the query and do something with it.
I don't want to write code on Scala end. Is it possible using bash or am I doing something wrong?
Thanks
You need to add escaped double-quotes within the double-quotes, like this:
sbt "run \"$str_opt\""

How to pass empty string as a command line property to Spring?

FYI: I am using Intellij's 'Run/Debug Configurations' tool.
I would like to pass an empty string as a property to my app via the command line:
--spring.ldap.username=
I have tried:
--spring.ldap.username= # results in parse error
--spring.ldap.username=''
--spring.ldap.username="" # results in parse error
--spring.ldap.username=\"\"
The attempts that actually parsed successfully yielded incorrect values, as demonstrated when I try to print the 'empty' Strings:
System.out.println(environment.getProperty("spring.ldap.username"));
// returns:
// ''
// ""
Setting the same property to an empty string in the application.properties file works perfectly:
spring.ldap.username=
The same print statement:
// returns:
//
// ^^ totally empty string
Is there a trick I am missing?
Try this: --spring.ldap.username (if you leave the =, it will parse as null)
So as it turns out, this can be accomplished by using regular JVM arguments.
Instead of
--my.property=
use
-Dmy.property=
Native JVM arguments are able to accept empty Strings I guess.
In IntelliJ, you can add them in the respective fields in the Run/Debug Configurations window as shown below:
This answer to another question also has some more information on passing JVM arguments to Spring applications.

How to generate PS1 in a function (escaping issues)

I'd like to move my bash prompt's construction into a function that can build it up modularly. The problem is that I cannot figure out how to get the function's result to be interpreted.
Example:
function build_prompt {
echo "\#"
}
export PS1="\$(build_prompt)"
My prompt always shows as \#, but should be the current time.
Sure there are ways around this particular example, but I'd like a general solution so I can use it for other escaped components, such as colours.
This is one use case for the PROMPT_COMMAND variable: running a function just before displaying the prompt that updates the value of PS1.
function build_prompt {
PS1='\#'
}
PROMPT_COMMAND='build_prompt'

Unix shell script to reformat the tabbing/indenting in code files based on curly braces

Unix shell script to reformat the tabbing/indenting in code files based on curly braces.
Looked around and found a way to do this in vim, using visual mode and the equals sign, but I can't seem to find a way to do it using an external unix shell script. The idea is to be able to run:
./scriptName filename(s)
And all files would be indented according to depth of curly braces. It doesn't have to add in extra newlines/return carriages, just indent based on depth.
namespace Mine {
Class Yours
{
Yours() { something something; }
~Yours() { something
something more }
Yours(too)
{
etc.
} } // Programmer put two braces on the same line, don't do anything
}
I can sort of imagine using an environment variable to keep track of the depth of braces, and then trimming the spaces on each line and adding spaces as needed, but I can't seem to figure it out. Any help would be really appreciated!
Try indent.

Resources