-
-
Notifications
You must be signed in to change notification settings - Fork 74
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
Issue 264 - Adds layout.csv to format output into columns #277
Issue 264 - Adds layout.csv to format output into columns #277
Conversation
Placing the file layout.csv in the config directory will allow the user to set the max lenght of any field. If the field is truncated then the last three characters are '...' to clearly indicate the field has been truncated. Example layout.csv contents: branch,symbols,branch_name,commit_msg,commit_time,path 20,7,27,30,10,100
gita/info.py
Outdated
@@ -9,6 +9,35 @@ | |||
from . import common | |||
|
|||
|
|||
class Truncate(): |
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.
This class loads the layout.csv file and is passed to the functions that generate text output. They can then call the truncate function to process their text output.
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.
()
can be deleted
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.
Thank you, I have removed them and pushed the fix.
@@ -113,8 +142,8 @@ def get_info_items() -> List[str]: | |||
return display_items | |||
|
|||
|
|||
def get_path(prop: Dict[str, str]) -> str: | |||
return f'{Color.cyan}{prop["path"]}{Color.end}' | |||
def get_path(prop: Dict[str, str], truncator: Truncate) -> str: |
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.
Here we pass in the Truncate class and the call the truncate member function to justify the text
@@ -421,13 +421,14 @@ def describe(repos: Dict[str, Dict[str, str]], no_colors: bool = False) -> str: | |||
Return the status of all repos | |||
""" | |||
if repos: | |||
truncator = info.Truncate() |
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.
We instantiate the Truncate class here so all threads will see the same values and the file only needs to be read once.
thanks for the contribution, it would be good to place a default closes #277 |
let me know if you are interested in adding the |
Good idea. I can give it a go but I doubt I'll have time this week. |
closes #264 I will add that today; thanks again for the feature |
please try 0.16.7.2 |
Just tried it and it looks good to me. But note I couldn't see it in the help with "gita -h" |
it's under |
Doh - yes it is :-) |
Placing the file layout.csv in the config directory will allow the user to set the max length of any field. If the field is truncated then the last three characters are '...' to clearly indicate the field has been truncated.
If the layout.csv file is not present then original formatting is generated.
By setting widths for all the columns the resulting output is tabulated.
The columns are: branch, symbols, branch_name, commit_msg, commit_time, path
Example layout.csv contents:
branch,symbols,branch_name,commit_msg,commit_time,path
20,7,27,30,10,100