11// Copyright (c) Zefchain Labs, Inc.
22// SPDX-License-Identifier: Apache-2.0
33
4- use std:: { num:: NonZeroU16 , path:: PathBuf } ;
4+ use std:: { borrow :: Cow , num:: NonZeroU16 , path:: PathBuf } ;
55
66use chrono:: { DateTime , Utc } ;
77use linera_base:: {
@@ -19,9 +19,8 @@ use linera_client::{
1919 util,
2020} ;
2121use linera_rpc:: config:: CrossChainConfig ;
22- use linera_service:: {
23- storage:: StorageConfigNamespace ,
24- util:: { DEFAULT_PAUSE_AFTER_GQL_MUTATIONS_SECS , DEFAULT_PAUSE_AFTER_LINERA_SERVICE_SECS } ,
22+ use linera_service:: util:: {
23+ DEFAULT_PAUSE_AFTER_GQL_MUTATIONS_SECS , DEFAULT_PAUSE_AFTER_LINERA_SERVICE_SECS ,
2524} ;
2625
2726#[ derive( Clone , clap:: Subcommand ) ]
@@ -784,87 +783,78 @@ pub enum ClientCommand {
784783 } ,
785784}
786785
786+ impl ClientCommand {
787+ /// Returns the log file name to use based on the [`ClientCommand`] that will run.
788+ pub fn log_file_name ( & self ) -> Cow < ' static , str > {
789+ match self {
790+ ClientCommand :: Transfer { .. }
791+ | ClientCommand :: OpenChain { .. }
792+ | ClientCommand :: OpenMultiOwnerChain { .. }
793+ | ClientCommand :: ChangeOwnership { .. }
794+ | ClientCommand :: ChangeApplicationPermissions { .. }
795+ | ClientCommand :: CloseChain { .. }
796+ | ClientCommand :: LocalBalance { .. }
797+ | ClientCommand :: QueryBalance { .. }
798+ | ClientCommand :: SyncBalance { .. }
799+ | ClientCommand :: Sync { .. }
800+ | ClientCommand :: ProcessInbox { .. }
801+ | ClientCommand :: QueryValidator { .. }
802+ | ClientCommand :: QueryValidators { .. }
803+ | ClientCommand :: SyncValidator { .. }
804+ | ClientCommand :: SetValidator { .. }
805+ | ClientCommand :: RemoveValidator { .. }
806+ | ClientCommand :: ResourceControlPolicy { .. }
807+ | ClientCommand :: FinalizeCommittee
808+ | ClientCommand :: CreateGenesisConfig { .. }
809+ | ClientCommand :: PublishModule { .. }
810+ | ClientCommand :: PublishDataBlob { .. }
811+ | ClientCommand :: ReadDataBlob { .. }
812+ | ClientCommand :: CreateApplication { .. }
813+ | ClientCommand :: PublishAndCreate { .. }
814+ | ClientCommand :: Keygen
815+ | ClientCommand :: Assign { .. }
816+ | ClientCommand :: Wallet { .. }
817+ | ClientCommand :: RetryPendingBlock { .. } => "client" . into ( ) ,
818+ #[ cfg( feature = "benchmark" ) ]
819+ ClientCommand :: Benchmark { .. } => "benchmark" . into ( ) ,
820+ ClientCommand :: Net { .. } => "net" . into ( ) ,
821+ ClientCommand :: Project { .. } => "project" . into ( ) ,
822+ ClientCommand :: Watch { .. } => "watch" . into ( ) ,
823+ ClientCommand :: Storage { .. } => "storage" . into ( ) ,
824+ ClientCommand :: Service { port, .. } => format ! ( "service-{port}" ) . into ( ) ,
825+ ClientCommand :: Faucet { .. } => "faucet" . into ( ) ,
826+ ClientCommand :: HelpMarkdown | ClientCommand :: ExtractScriptFromMarkdown { .. } => {
827+ "tool" . into ( )
828+ }
829+ }
830+ }
831+ }
832+
787833#[ derive( Clone , clap:: Parser ) ]
788834pub enum DatabaseToolCommand {
789835 /// Delete all the namespaces in the database
790- #[ command( name = "delete_all" ) ]
791- DeleteAll {
792- /// Storage configuration for the blockchain history.
793- #[ arg( long = "storage" ) ]
794- storage_config : String ,
795- } ,
836+ DeleteAll ,
796837
797838 /// Delete a single namespace from the database
798- #[ command( name = "delete_namespace" ) ]
799- DeleteNamespace {
800- /// Storage configuration for the blockchain history.
801- #[ arg( long = "storage" ) ]
802- storage_config : String ,
803- } ,
839+ DeleteNamespace ,
804840
805841 /// Check existence of a namespace in the database
806- #[ command( name = "check_existence" ) ]
807- CheckExistence {
808- /// Storage configuration for the blockchain history.
809- #[ arg( long = "storage" ) ]
810- storage_config : String ,
811- } ,
812-
813- /// Check absence of a namespace in the database
814- #[ command( name = "check_absence" ) ]
815- CheckAbsence {
816- /// Storage configuration for the blockchain history.
817- #[ arg( long = "storage" ) ]
818- storage_config : String ,
819- } ,
842+ CheckExistence ,
820843
821844 /// Initialize a namespace in the database
822- #[ command( name = "initialize" ) ]
823845 Initialize {
824- /// Storage configuration for the blockchain history.
825- #[ arg( long = "storage" ) ]
826- storage_config : String ,
846+ #[ arg( long = "genesis" ) ]
847+ genesis_config_path : PathBuf ,
827848 } ,
828849
829850 /// List the namespaces in the database
830- #[ command( name = "list_namespaces" ) ]
831- ListNamespaces {
832- /// Storage configuration for the blockchain history.
833- #[ arg( long = "storage" ) ]
834- storage_config : String ,
835- } ,
851+ ListNamespaces ,
836852
837853 /// List the blob IDs in the database
838- #[ command( name = "list_blob_ids" ) ]
839- ListBlobIds {
840- /// Storage configuration for the blockchain history.
841- #[ arg( long = "storage" ) ]
842- storage_config : String ,
843- } ,
854+ ListBlobIds ,
844855
845856 /// List the chain IDs in the database
846- #[ command( name = "list_chain_ids" ) ]
847- ListChainIds {
848- /// Storage configuration for the blockchain history.
849- #[ arg( long = "storage" ) ]
850- storage_config : String ,
851- } ,
852- }
853-
854- impl DatabaseToolCommand {
855- pub fn storage_config ( & self ) -> Result < StorageConfigNamespace , anyhow:: Error > {
856- let storage_config = match self {
857- DatabaseToolCommand :: DeleteAll { storage_config } => storage_config,
858- DatabaseToolCommand :: DeleteNamespace { storage_config } => storage_config,
859- DatabaseToolCommand :: CheckExistence { storage_config } => storage_config,
860- DatabaseToolCommand :: CheckAbsence { storage_config } => storage_config,
861- DatabaseToolCommand :: Initialize { storage_config } => storage_config,
862- DatabaseToolCommand :: ListNamespaces { storage_config } => storage_config,
863- DatabaseToolCommand :: ListBlobIds { storage_config } => storage_config,
864- DatabaseToolCommand :: ListChainIds { storage_config } => storage_config,
865- } ;
866- storage_config. parse :: < StorageConfigNamespace > ( )
867- }
857+ ListChainIds ,
868858}
869859
870860#[ allow( clippy:: large_enum_variant) ]
@@ -933,11 +923,6 @@ pub enum NetCommand {
933923 #[ arg( long) ]
934924 path : Option < String > ,
935925
936- /// Run with a specific storage.
937- /// If none, then a linera-storage-service is started on a random free port.
938- #[ arg( long) ]
939- storage : Option < String > ,
940-
941926 /// External protocol used, either `grpc` or `grpcs`.
942927 #[ arg( long, default_value = "grpc" ) ]
943928 external_protocol : String ,
0 commit comments