- 
                Notifications
    
You must be signed in to change notification settings  - Fork 89
 
feat: Implement toml config for fmt command. #205
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
          
     Merged
      
      
    
  
     Merged
                    Changes from 1 commit
      Commits
    
    
            Show all changes
          
          
            6 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      c29a0ef
              
                Implement toml config for fmt command.
              
              
                wxsBSD 812afb3
              
                Add .swp to gitignore.
              
              
                wxsBSD 4481fdb
              
                Improve config file handling.
              
              
                wxsBSD 9bbd716
              
                Implement tabs and spaces support.
              
              
                wxsBSD a5014ab
              
                style: fix Clippy warnings
              
              
                plusvic b599262
              
                refactor: move the `config` module to the CLI
              
              
                plusvic File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -1 +1,85 @@ | ||
| # XXX: Add docs on how config file works. | ||
| YARA-X Config Guide | ||
| =================== | ||
| 
     | 
||
| YARA-X uses a configuration file for controlling the behavior of different | ||
| commands. It currently supports the fmt command, but others will be added in the | ||
| future. | ||
| 
     | 
||
| The `yr` command looks in `${HOME}/.yara-x.toml` when starting up. If that file | ||
| does not exist the default values are used. | ||
| 
     | 
||
| An example `.yara-x.toml` file is below, with comments that explain each option. | ||
| This is the definitive list of supported configuration options, and will be | ||
| updated as more are added. | ||
| 
     | 
||
| ```toml | ||
| # Config file for YARA-X. | ||
| 
     | 
||
| # Any options that are not valid are ignored. However, valid keys with an | ||
| # invalid type will cause a parsing error. For example, if you set | ||
| # rule.indent_spaces to false, it will result in a parsing error. | ||
| pants = false # Invalid keys are ignored. | ||
| 
     | 
||
| # The configuration of the "fmt" subcommand can be controlled by options in the | ||
| # "fmt" section. Each line is a key-value pair where the key uses a dot notation | ||
| # to deliniate different options. The "rule" namespace are for options that | ||
| # apply to the rule as a whole, while the "meta" and "patterns" namespaces are | ||
| # for options that only apply to those sections in a rule. | ||
| [fmt] | ||
| # Indent section headers so that: | ||
| # | ||
| # rule a { | ||
| # condition: | ||
| # true | ||
| # } | ||
| # | ||
| # Becomes: | ||
| # | ||
| # rule a { | ||
| # condition: | ||
| # true | ||
| # } | ||
| rule.indent_section_headers = true | ||
| 
     | 
||
| # Indent section contents so that: | ||
| # rule a { | ||
| # condition: | ||
| # true | ||
| # } | ||
| # | ||
| # Becomes: | ||
| # | ||
| # rule a { | ||
| # condition: | ||
| # true | ||
| # } | ||
| rule.indent_section_contents = true | ||
| 
     | 
||
| # Number of spaces to use for indentation. Setting this to 0 will use one tab | ||
| # character per level of indentation. To disable indentation entirely use | ||
| # rule.indent_section_headers and rule.indent_section_contents | ||
| rule.indent_spaces = 2 | ||
| 
     | 
||
| # Align metadata values so that: | ||
| # | ||
| # rule a { | ||
| # meta: | ||
| # key = "a" | ||
| # long_key = "b" | ||
| # } | ||
| # | ||
| # Becomes: | ||
| # | ||
| # rule a { | ||
| # meta: | ||
| # key = "a" | ||
| # long_key = "b" | ||
| # } | ||
| # | ||
| # Note that alignment is done with spaces, regardless of rule.indent_spaces | ||
| # setting. | ||
| meta.align_values = false | ||
| 
     | 
||
| # Same as meta.align_values but applies to patterns. | ||
| patterns.align_values = false | ||
| ``` | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
      
      Oops, something went wrong.
        
    
  
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@plusvic I'm not sure this is the right way to do this.