@@ -1755,17 +1755,21 @@ impl ClientOptions {
17551755 . unwrap_or_default ( )
17561756 }
17571757
1758- fn config_path ( ) -> Result < PathBuf , Error > {
1759- let mut config_dir = dirs:: config_dir ( ) . ok_or_else ( || anyhow ! (
1758+ fn config_path ( & self , file : & str ) -> Result < PathBuf , Error > {
1759+ let mut path = self . context_options . home_directory . clone ( ) . or_else ( dirs:: config_dir) . ok_or_else ( || anyhow ! (
17601760 "Default wallet directory is not supported in this platform: please specify storage and wallet paths"
17611761 ) ) ?;
1762- config_dir. push ( "linera" ) ;
1763- if !config_dir. exists ( ) {
1764- debug ! ( "Creating default wallet directory {}" , config_dir. display( ) ) ;
1765- fs_err:: create_dir_all ( & config_dir) ?;
1762+ path. push ( "linera" ) ;
1763+ if let Some ( name) = & self . context_options . with_wallet {
1764+ path. push ( name) ;
17661765 }
1767- info ! ( "Using default wallet directory {}" , config_dir. display( ) ) ;
1768- Ok ( config_dir)
1766+ if !path. exists ( ) {
1767+ debug ! ( "Creating default wallet directory {}" , path. display( ) ) ;
1768+ fs_err:: create_dir_all ( & path) ?;
1769+ }
1770+ path. push ( file) ;
1771+ info ! ( "Using wallet path {}" , path. display( ) ) ;
1772+ Ok ( path)
17691773 }
17701774
17711775 fn storage_config ( & self ) -> Result < StorageConfig , Error > {
@@ -1775,14 +1779,15 @@ impl ClientOptions {
17751779 let suffix = self . suffix ( ) ;
17761780 let storage_env_var = env:: var ( format ! ( "LINERA_STORAGE{suffix}" ) ) . ok ( ) ;
17771781 if let Some ( config) = storage_env_var {
1782+ warn ! ( "LINERA_STORAGE_* is deprecated. Use --with-wallet=NAME or --storage=CONFIG instead." ) ;
17781783 return config. parse ( ) ;
17791784 }
17801785 cfg_if:: cfg_if! {
17811786 if #[ cfg( feature = "rocksdb" ) ] {
17821787 let spawn_mode =
17831788 linera_views:: rocks_db:: RocksDbSpawnMode :: get_spawn_mode_from_runtime( ) ;
17841789 let inner_storage_config = linera_service:: storage:: InnerStorageConfig :: RocksDb {
1785- path: Self :: config_path( ) ? . join ( "wallet.db" ) ,
1790+ path: self . config_path( "wallet.db" ) ? ,
17861791 spawn_mode,
17871792 } ;
17881793 let namespace = "default" . to_string( ) ;
@@ -1798,28 +1803,30 @@ impl ClientOptions {
17981803
17991804 fn wallet_path ( & self ) -> Result < PathBuf , Error > {
18001805 if let Some ( path) = & self . context_options . wallet_state_path {
1806+ warn ! ( "Option --wallet is deprecated. Use --with-wallet=NAME instead." ) ;
18011807 return Ok ( path. clone ( ) ) ;
18021808 }
18031809 let suffix = self . suffix ( ) ;
18041810 let wallet_env_var = env:: var ( format ! ( "LINERA_WALLET{suffix}" ) ) . ok ( ) ;
18051811 if let Some ( path) = wallet_env_var {
1812+ warn ! ( "LINERA_WALLET_* is deprecated. Use --with-wallet=NAME instead." ) ;
18061813 return Ok ( path. parse ( ) ?) ;
18071814 }
1808- let config_path = Self :: config_path ( ) ?;
1809- Ok ( config_path. join ( "wallet.json" ) )
1815+ self . config_path ( "wallet.json" )
18101816 }
18111817
18121818 fn keystore_path ( & self ) -> Result < PathBuf , Error > {
18131819 if let Some ( path) = & self . context_options . keystore_path {
1820+ warn ! ( "Option --keystore is deprecated. Use --with-wallet=NAME instead." ) ;
18141821 return Ok ( path. clone ( ) ) ;
18151822 }
18161823 let suffix = self . suffix ( ) ;
18171824 let keystore_env_var = env:: var ( format ! ( "LINERA_KEYSTORE{suffix}" ) ) . ok ( ) ;
18181825 if let Some ( path) = keystore_env_var {
1826+ warn ! ( "LINERA_KEYSTORE_* is deprecated. Use --with-wallet=NAME instead." ) ;
18191827 return Ok ( path. parse ( ) ?) ;
18201828 }
1821- let config_path = Self :: config_path ( ) ?;
1822- Ok ( config_path. join ( "keystore.json" ) )
1829+ self . config_path ( "keystore.json" )
18231830 }
18241831
18251832 pub fn create_wallet (
0 commit comments