77import argparse
88
99from west .commands import CommandError , WestCommand
10- from west .configuration import ConfigFile
10+ from west .configuration import ConfigFile , Configuration
1111
1212CONFIG_DESCRIPTION = '''\
1313 West configuration file handling.
7474To delete <name> everywhere it's set, including the system file:
7575 west config -D <name>
7676
77- Additionally to the config file a dropin config directory is considered.
78- The directory is named as the according config file, but with a '.d' suffix.
79- As a result there are three levels for dropin config directories (local, global
80- and system), whereby all '.conf' files from each dropin directory are loaded in
81- alphabetical order.
77+ For each configuration type (local, global, and system), an additional
78+ drop-in directory is supported. This directory is named after the configuration
79+ file with a `.d` suffix.
80+
81+ All files inside a drop-in directory must use `.conf` extension and are
82+ loaded in **alphabetical order**.
8283For example:
8384 .west/config.d/basics.conf
85+
86+ To list the configuration files that are loaded (both the main config file
87+ and all drop-ins) in the exact order they were applied (where later values
88+ override earlier ones):
89+ west config --list-paths
90+ west config --local --list-paths
91+ west config --global --list-paths
92+ west config --system --list-paths
8493'''
8594
8695CONFIG_EPILOG = '''\
@@ -113,9 +122,12 @@ def do_add_parser(self, parser_adder):
113122 "action to perform (give at most one)"
114123 ).add_mutually_exclusive_group ()
115124
116- group .add_argument ('-p' , '--print-path' , action = 'store_true' ,
117- help = 'print file path from according west config'
118- '(--system, --global, --local)' )
125+ group .add_argument ('--print-path' , action = 'store_true' ,
126+ help = 'print the file path from according west '
127+ 'config (--local [default], --global, --system)' )
128+ group .add_argument ('--list-paths' , action = 'store_true' ,
129+ help = 'list all config files and dropin files that '
130+ 'are currently considered by west config' )
119131 group .add_argument ('-l' , '--list' , action = 'store_true' ,
120132 help = 'list all options and their values' )
121133 group .add_argument ('-d' , '--delete' , action = 'store_true' ,
@@ -151,7 +163,7 @@ def do_run(self, args, user_args):
151163 if args .list :
152164 if args .name :
153165 self .parser .error ('-l cannot be combined with name argument' )
154- elif not args .name and not args .print_path :
166+ elif not any ([ args .name , args .print_path , args . list_paths ]) :
155167 self .parser .error ('missing argument name '
156168 '(to list all options and values, use -l)' )
157169 elif args .append :
@@ -160,6 +172,8 @@ def do_run(self, args, user_args):
160172
161173 if args .print_path :
162174 self .print_path (args )
175+ elif args .list_paths :
176+ self .list_paths (args )
163177 elif args .list :
164178 self .list (args )
165179 elif delete :
@@ -176,6 +190,11 @@ def print_path(self, args):
176190 if config_path :
177191 print (config_path )
178192
193+ def list_paths (self , args ):
194+ config_paths = Configuration ().get_paths (args .configfile or ALL )
195+ for config_path in config_paths :
196+ print (config_path )
197+
179198 def list (self , args ):
180199 what = args .configfile or ALL
181200 for option , value in self .config .items (configfile = what ):
0 commit comments