@@ -110,60 +110,65 @@ func parseHostPort(hostPort string) (string, int, error) {
110110func ParseConnectionArgs (args []string ) (* ConnectionArgs , error ) {
111111 // First, scan args to check for help, config file, and admin mode
112112 var configFilePath string
113-
113+ var adminMode bool = false
114114 for i := 0 ; i < len (args ); i ++ {
115115 arg := args [i ]
116116 if arg == "--help" || arg == "-help" {
117117 return & ConnectionArgs {ShowHelp : true }, nil
118118 } else if (arg == "-f" || arg == "--config" ) && i + 1 < len (args ) {
119119 configFilePath = args [i + 1 ]
120120 i ++
121+ } else if arg == "--admin" {
122+ adminMode = true
121123 }
122124 }
123125
124126 // Load config file with priority: -f > rf.yml > none
125127 var config * ConfigFile
126128 var err error
127129
128- if configFilePath != "" {
129- // User specified config file via -f
130- config , err = LoadConfigFileFromPath (configFilePath )
131- if err != nil {
132- return nil , err
133- }
134- } else {
135- // Try default rf.yml
136- config , err = LoadDefaultConfigFile ()
137- if err != nil {
138- return nil , err
139- }
140- }
141-
142130 // Parse arguments manually to support both short and long forms
143131 // and to handle priority: command line > config file > defaults
144132
145133 // Build result from config file first (if exists), then override with command line flags
146134 result := & ConnectionArgs {}
147135
148- // Get non-flag arguments (command to execute)
149- var nonFlagArgs []string
150-
151- // Apply config file values first (lower priority)
152- if config != nil {
153- // Parse host:port from config file
154- if config .Host != "" {
155- h , port , err := parseHostPort (config .Host )
136+ if ! adminMode {
137+ // Only user mode read config file
138+ if configFilePath != "" {
139+ // User specified config file via -f
140+ config , err = LoadConfigFileFromPath (configFilePath )
141+ if err != nil {
142+ return nil , err
143+ }
144+ } else {
145+ // Try default rf.yml
146+ config , err = LoadDefaultConfigFile ()
156147 if err != nil {
157- return nil , fmt .Errorf ("invalid host in config file: %v" , err )
148+ return nil , err
149+ }
150+ }
151+
152+ // Apply config file values first (lower priority)
153+ if config != nil {
154+ // Parse host:port from config file
155+ if config .Host != "" {
156+ h , port , err := parseHostPort (config .Host )
157+ if err != nil {
158+ return nil , fmt .Errorf ("invalid host in config file: %v" , err )
159+ }
160+ result .Host = h
161+ result .Port = port
158162 }
159- result .Host = h
160- result .Port = port
163+ result .UserName = config .UserName
164+ result .Password = config .Password
165+ result .APIToken = config .APIToken
161166 }
162- result .UserName = config .UserName
163- result .Password = config .Password
164- result .APIToken = config .APIToken
165167 }
166168
169+ // Get non-flag arguments (command to execute)
170+ var nonFlagArgs []string
171+
167172 // Override with command line flags (higher priority)
168173 // Handle both short and long forms manually
169174 for i := 0 ; i < len (args ); i ++ {
0 commit comments