2012-05-07 15:07:23 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Read configuration settings.
|
|
|
|
*
|
|
|
|
* @group workflow
|
|
|
|
*/
|
|
|
|
final class ArcanistGetConfigWorkflow extends ArcanistBaseWorkflow {
|
|
|
|
|
Make Arcanist workflow names explicit
Summary:
Currently, adding a new workflow requires you to override ArcanistConfiguration, which is messy. Instead, just load everything that extends ArcanistBaseWorkflow.
Remove all the rules tying workflow names to class names through arcane incantations.
This has a very small performance cost in that we need to load every Workflow class every time now, but we don't hit __init__ and such anymore and it was pretty negligible on my machine (98ms vs 104ms or something).
Test Plan: Ran "arc help", "arc which", "arc diff", etc.
Reviewers: edward, vrana, btrahan
Reviewed By: edward
CC: aran, zeeg
Differential Revision: https://secure.phabricator.com/D3691
2012-10-17 17:35:03 +02:00
|
|
|
public function getWorkflowName() {
|
|
|
|
return 'get-config';
|
|
|
|
}
|
|
|
|
|
2012-05-07 15:07:23 +02:00
|
|
|
public function getCommandSynopses() {
|
|
|
|
return phutil_console_format(<<<EOTEXT
|
2012-06-14 01:02:29 +02:00
|
|
|
**get-config** -- [__name__ ...]
|
2012-05-07 15:07:23 +02:00
|
|
|
EOTEXT
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getCommandHelp() {
|
|
|
|
return phutil_console_format(<<<EOTEXT
|
|
|
|
Supports: cli
|
Enrich arc configuration and add stronger typing
Summary:
See <https://github.com/facebook/arcanist/issues/45>
Currently, when the user types `arc set-config x false`, we set it as the string "false", which is usually not desirable. We have some steps toward typed config already, but expand on what we have and move as much stuff as possible into it, including all the config settings that aren't currently documented (there are still some lint-specific and project-specific settings not present here, but this is most of it).
Also make the `phutil_libraries` key a legacy name for `load`, and `immutable_history` a legacy name for `history.immutable`. Generally the goal here is to make config simpler and bring it more in-line with Git/Mercurial, which use dotted hierarchies.
I'll add some documentation here but I think most of the changes should be fairly straightforward.
Test Plan:
- `arc set-config history.immutable on` (And similar -- sets to boolean true.)
- `arc set-config history.immutable off` (And similar -- sets to boolean false.)
- `arc set-config history.immutable derp` (And similar -- raises exception.)
- `arc set-config history.immutable ''` (And similar -- removes setting value.)
- `arc set-config --show`
- `arc get-config`
- `arc get-config base`
Reviewers: dschleimer, bos, btrahan, vrana
Reviewed By: dschleimer
CC: aran
Maniphest Tasks: T1546
Differential Revision: https://secure.phabricator.com/D3045
2012-07-26 03:37:09 +02:00
|
|
|
Reads an arc configuration option. With no argument, reads all
|
2012-05-07 15:07:23 +02:00
|
|
|
options.
|
|
|
|
EOTEXT
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getArguments() {
|
|
|
|
return array(
|
|
|
|
'*' => 'argv',
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2012-06-14 01:02:29 +02:00
|
|
|
public function desiresRepositoryAPI() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-05-07 15:07:23 +02:00
|
|
|
public function run() {
|
|
|
|
$argv = $this->getArgument('argv');
|
|
|
|
|
Enrich arc configuration and add stronger typing
Summary:
See <https://github.com/facebook/arcanist/issues/45>
Currently, when the user types `arc set-config x false`, we set it as the string "false", which is usually not desirable. We have some steps toward typed config already, but expand on what we have and move as much stuff as possible into it, including all the config settings that aren't currently documented (there are still some lint-specific and project-specific settings not present here, but this is most of it).
Also make the `phutil_libraries` key a legacy name for `load`, and `immutable_history` a legacy name for `history.immutable`. Generally the goal here is to make config simpler and bring it more in-line with Git/Mercurial, which use dotted hierarchies.
I'll add some documentation here but I think most of the changes should be fairly straightforward.
Test Plan:
- `arc set-config history.immutable on` (And similar -- sets to boolean true.)
- `arc set-config history.immutable off` (And similar -- sets to boolean false.)
- `arc set-config history.immutable derp` (And similar -- raises exception.)
- `arc set-config history.immutable ''` (And similar -- removes setting value.)
- `arc set-config --show`
- `arc get-config`
- `arc get-config base`
Reviewers: dschleimer, bos, btrahan, vrana
Reviewed By: dschleimer
CC: aran
Maniphest Tasks: T1546
Differential Revision: https://secure.phabricator.com/D3045
2012-07-26 03:37:09 +02:00
|
|
|
$settings = new ArcanistSettings();
|
|
|
|
|
2013-10-19 01:10:06 +02:00
|
|
|
$configuration_manager = $this->getConfigurationManager();
|
2012-06-14 01:02:29 +02:00
|
|
|
$configs = array(
|
2013-10-19 01:10:06 +02:00
|
|
|
ArcanistConfigurationManager::CONFIG_SOURCE_SYSTEM =>
|
|
|
|
$configuration_manager->readSystemArcConfig(),
|
|
|
|
ArcanistConfigurationManager::CONFIG_SOURCE_USER =>
|
|
|
|
$configuration_manager->readUserArcConfig(),
|
|
|
|
ArcanistConfigurationManager::CONFIG_SOURCE_PROJECT =>
|
|
|
|
$this->getWorkingCopy()->readProjectConfig(),
|
|
|
|
ArcanistConfigurationManager::CONFIG_SOURCE_LOCAL =>
|
|
|
|
$configuration_manager->readLocalArcConfig(),
|
2012-06-14 01:02:29 +02:00
|
|
|
);
|
2012-07-26 05:14:28 +02:00
|
|
|
|
2012-05-07 15:07:23 +02:00
|
|
|
if ($argv) {
|
|
|
|
$keys = $argv;
|
|
|
|
} else {
|
2012-06-14 01:02:29 +02:00
|
|
|
$keys = array_mergev(array_map('array_keys', $configs));
|
|
|
|
$keys = array_unique($keys);
|
2012-05-07 15:07:23 +02:00
|
|
|
sort($keys);
|
|
|
|
}
|
|
|
|
|
2012-07-26 05:14:28 +02:00
|
|
|
$multi = (count($keys) > 1);
|
|
|
|
|
2012-05-07 15:07:23 +02:00
|
|
|
foreach ($keys as $key) {
|
2012-07-26 05:14:28 +02:00
|
|
|
if ($multi) {
|
|
|
|
echo "{$key}\n";
|
|
|
|
}
|
2012-06-14 01:02:29 +02:00
|
|
|
foreach ($configs as $name => $config) {
|
2012-07-26 05:14:28 +02:00
|
|
|
switch ($name) {
|
2013-10-19 01:10:06 +02:00
|
|
|
case ArcanistConfigurationManager::CONFIG_SOURCE_PROJECT:
|
2012-07-26 05:14:28 +02:00
|
|
|
// Respect older names in project config.
|
2013-10-23 00:34:06 +02:00
|
|
|
$val = $this->getWorkingCopy()->getProjectConfig($key);
|
2012-07-26 05:14:28 +02:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
$val = idx($config, $key);
|
|
|
|
break;
|
|
|
|
}
|
Enrich arc configuration and add stronger typing
Summary:
See <https://github.com/facebook/arcanist/issues/45>
Currently, when the user types `arc set-config x false`, we set it as the string "false", which is usually not desirable. We have some steps toward typed config already, but expand on what we have and move as much stuff as possible into it, including all the config settings that aren't currently documented (there are still some lint-specific and project-specific settings not present here, but this is most of it).
Also make the `phutil_libraries` key a legacy name for `load`, and `immutable_history` a legacy name for `history.immutable`. Generally the goal here is to make config simpler and bring it more in-line with Git/Mercurial, which use dotted hierarchies.
I'll add some documentation here but I think most of the changes should be fairly straightforward.
Test Plan:
- `arc set-config history.immutable on` (And similar -- sets to boolean true.)
- `arc set-config history.immutable off` (And similar -- sets to boolean false.)
- `arc set-config history.immutable derp` (And similar -- raises exception.)
- `arc set-config history.immutable ''` (And similar -- removes setting value.)
- `arc set-config --show`
- `arc get-config`
- `arc get-config base`
Reviewers: dschleimer, bos, btrahan, vrana
Reviewed By: dschleimer
CC: aran
Maniphest Tasks: T1546
Differential Revision: https://secure.phabricator.com/D3045
2012-07-26 03:37:09 +02:00
|
|
|
if ($val === null) {
|
|
|
|
continue;
|
2012-06-14 01:02:29 +02:00
|
|
|
}
|
Enrich arc configuration and add stronger typing
Summary:
See <https://github.com/facebook/arcanist/issues/45>
Currently, when the user types `arc set-config x false`, we set it as the string "false", which is usually not desirable. We have some steps toward typed config already, but expand on what we have and move as much stuff as possible into it, including all the config settings that aren't currently documented (there are still some lint-specific and project-specific settings not present here, but this is most of it).
Also make the `phutil_libraries` key a legacy name for `load`, and `immutable_history` a legacy name for `history.immutable`. Generally the goal here is to make config simpler and bring it more in-line with Git/Mercurial, which use dotted hierarchies.
I'll add some documentation here but I think most of the changes should be fairly straightforward.
Test Plan:
- `arc set-config history.immutable on` (And similar -- sets to boolean true.)
- `arc set-config history.immutable off` (And similar -- sets to boolean false.)
- `arc set-config history.immutable derp` (And similar -- raises exception.)
- `arc set-config history.immutable ''` (And similar -- removes setting value.)
- `arc set-config --show`
- `arc get-config`
- `arc get-config base`
Reviewers: dschleimer, bos, btrahan, vrana
Reviewed By: dschleimer
CC: aran
Maniphest Tasks: T1546
Differential Revision: https://secure.phabricator.com/D3045
2012-07-26 03:37:09 +02:00
|
|
|
$val = $settings->formatConfigValueForDisplay($key, $val);
|
|
|
|
printf("% 10.10s: %s\n", $name, $val);
|
2012-06-14 01:02:29 +02:00
|
|
|
}
|
2012-07-26 05:14:28 +02:00
|
|
|
if ($multi) {
|
|
|
|
echo "\n";
|
|
|
|
}
|
2012-05-07 15:07:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|