TOML how to have key without value - toml

Many Python tools these days are using pyproject.toml as a config file, and mirror the tool's command line arguments with config file keys. Tools may have command line flags that are not passed any arguments:
sometool --some-flag
Now, I am trying to place this --some-flag into a pyproject.toml config file and can't figure out how to have a key without any value.
[tool.sometool]
# Both of the below are invalid
some-flag
some-flag =
In TOML, is it possible to have a key without a value?

This is not possible.
It'd depend on the tool how they are doing this, so please refer to their documentation. I would guess they are treating those flags as a boolean.
[tool.sometool]
some-flag = true

Related

Is there a way to specify the output path of .coverage?

I'm looking for a way to specify the output path of the generated .coverage file. I've checked coverage help and did some research but still no luck so far. The reason is that I would like it to be specified into our tmp directory.
You can create a .coveragerc and specify the path for .coverage using the data_file attribute under the [run] section.
This is the link to the current documentation.
You can use the [run] data_file setting (https://coverage.readthedocs.io/en/latest/config.html#run), or the COVERAGE_FILE environment variable (https://coverage.readthedocs.io/en/latest/cmd.html#data-file).

Using Config::Simple to read MySQL config file with keys without values

I try to configure my mySql config file with perl.
I use config::simple for doing this.
my code is:
#!/bin/perl
use Config::Simple;
$cfg = new Config::Simple('/etc/mysql/my.cnf');
$cfg->param('bind-address', '192.168.1.11');
$cfg->save();
the problem is that I get an error when a row only has a key and not an value to it. How do I fix this problem?
To extend simbabque's comment I would suggest using Config::MySQL to deal with MySQL config files.
Config::MySQL extends Config::INI to support reading and writing
MySQL-style configuration files. Although deceptively similar to
standard .INI files, they can include bare boolean options with no
value assignment and additional features like !include and
!includedir.

Preventing the accidentally marking of all conflicts as resolved in Mercurial

It doesn't happen too often, but every once in a while I'll fumble with my typing and accidentally invoke "hg resolve -m" without a file argument. This then helpfully marks all the conflicts resolved. Is there any way to prevent it from resolving without one or more file arguments?
You can do this with a pre-resolve hook but you'd have to parse the arguments yourself to ensure that they are valid which could be tricky.
The relevant environment variables that you might need to look at are:
HG_ARGS - the contents of the whole command line e.g. resolve -m
HG_OPTS - a dictionary object containing options specified. This would have an an entry called mark with a value of True if -m had been specified
HG_PATS - this is the list of files specified
Depending upon the scripting language you would use, you should be able to test if HG_OPTS contains a value of True for mark and fail if it does and the HG_PATS array is empty.
It starts to get complicated when you take into account the --include and --exclude arguments.
If you specify the files to resolve as part of the --include option then the files to include would be in HG_OPTS, not HG_PATS. Also, I don't know what would happen if you specified hg resolve -m test.txt --exclude test.txt. I'd hope that it would not resolve anything but you'd need to test that.
Once you've parsed the command arguments, you'd return either 0 to allow the command or 1 to prevent it. You should echo a reason for the failure if you return 1 to avoid confusion later.
If you don't know how to do this then you'd need to specify what OS and shell you are using for anyone to provide more specific help.

scripting buildroot configuration file

I am trying to switch between external and internal build via some export variable in a script. I am able to do this partially meaning for bool values but for those which take in strings how to tell buildroot to continue with default value and not prompt for values to the user.
For e.g., BR2_TOOLCHAIN_EXTERNAL_STRIP=y works fine, as it takes in bool value, but BR2_TOOLCHAIN_EXTERNAL_PATH prompts for a value, even though default is set to the correct path.
Thanks for any help
If you want to switch easily between internal and external toolchain builds, then I would suggest creating fragments of defconfig files:
One defining the internal toolchain configuration
One defining the external toolchain configuration
One defining the common options
And then, you just to :
cat internal-toolchain.config common.config > configs/myown_defconfig
make myown_defconfig
and there you are. And similarly with external-toolchain.config.

using property file along with config file to be used with mxmlc

I'm trying to run mxmlc in the following manner.
mxmlc -load-config+=mycfg.xml C:\\projects\\src\\main.mxml -output myswf.swf
In the config file, I want to keep some values configurable, for example the paths of the external libraries. Is it possible to include a property file into the config file and use it as {property_name} in the config file?
Or is it possible to pass certain arguments from the command line itself that will override/replace the corresponding values in the config file, like the -D option in the ant command?
Please provide your suggestions.
From the LiveDocs for mxmlc / -load-config:
If you specify a configuration file,
you can override individual options by
setting them on the command line.