Skip to content
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

Merged

Conversation

PapaRoskitos
Copy link
Contributor

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

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():
Copy link
Contributor Author

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.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

() can be deleted

Copy link
Contributor Author

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:
Copy link
Contributor Author

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()
Copy link
Contributor Author

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.

@nosarthur
Copy link
Owner

thanks for the contribution, it would be good to place a default layout.csv upon user's request, say via gita info set-lengths (or some better name?), and it would also print out where layout.csv is

closes #277

@nosarthur
Copy link
Owner

let me know if you are interested in adding the gita info sub-command. If not, I will add that after merging this PR

@PapaRoskitos
Copy link
Contributor Author

thanks for the contribution, it would be good to place a default layout.csv upon user's request, say via gita info set-lengths (or some better name?), and it would also print out where layout.csv is

closes #277

Good idea. I can give it a go but I doubt I'll have time this week.

@nosarthur nosarthur merged commit 6ce0174 into nosarthur:master Jun 13, 2024
15 checks passed
@nosarthur
Copy link
Owner

closes #264

I will add that today; thanks again for the feature

@nosarthur
Copy link
Owner

please try 0.16.7.2

@PapaRoskitos
Copy link
Contributor Author

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"

@PapaRoskitos PapaRoskitos deleted the Iss264-Limit-gita-ll-column-widths branch June 13, 2024 19:15
@nosarthur
Copy link
Owner

it's under gita info -h

@PapaRoskitos
Copy link
Contributor Author

it's under gita info -h

Doh - yes it is :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants