Add complete account dump to file
This commit introduces the ability to dump the complete content of an
account to a JSON file (compact or not depending on the provided format
option).
Example:
```sh
solana account -u m \
  --output json-compact \
  --output-file SRM_token.json \
  SRMuApVNdxXokk5GT7XD5cUUgXMBCoAz2LHeuAoKWRt
```
Note: Behavior remains untouched if format option `--output` is not
provided (only account data gets written to file).
(cherry picked from commit 0e9e67b65d)
			
			
This commit is contained in:
		@@ -462,9 +462,16 @@ pub fn process_show_account(
 | 
			
		||||
 | 
			
		||||
    let mut account_string = config.output_format.formatted_string(&cli_account);
 | 
			
		||||
 | 
			
		||||
    if config.output_format == OutputFormat::Display
 | 
			
		||||
        || config.output_format == OutputFormat::DisplayVerbose
 | 
			
		||||
    {
 | 
			
		||||
    match config.output_format {
 | 
			
		||||
        OutputFormat::Json | OutputFormat::JsonCompact => {
 | 
			
		||||
            if let Some(output_file) = output_file {
 | 
			
		||||
                let mut f = File::create(output_file)?;
 | 
			
		||||
                f.write_all(account_string.as_bytes())?;
 | 
			
		||||
                writeln!(&mut account_string)?;
 | 
			
		||||
                writeln!(&mut account_string, "Wrote account to {}", output_file)?;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        OutputFormat::Display | OutputFormat::DisplayVerbose => {
 | 
			
		||||
            if let Some(output_file) = output_file {
 | 
			
		||||
                let mut f = File::create(output_file)?;
 | 
			
		||||
                f.write_all(&data)?;
 | 
			
		||||
@@ -475,6 +482,8 @@ pub fn process_show_account(
 | 
			
		||||
                writeln!(&mut account_string, "{:?}", data.hex_dump())?;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        OutputFormat::DisplayQuiet => (),
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    Ok(account_string)
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user