Open namespaceYcZ opened 2 months ago
Hello @namespaceYcZ
Yes this a thing that is planned for later, a dedicated directory inside the system would be great. It is not implemeted yet because I don't know how make it cross-platform. But your solution seems good to me, I'll look into it further.
Have you tried using the ATAC_MAIN_DIR
env variable before the features comes out?
Have a great day
PS: do you have more knowledge on how to implement those things? I have some questions
Hello @namespaceYcZ
Yes this a thing that is planned for later, a dedicated directory inside the system would be great. It is not implemeted yet because I don't know how make it cross-platform. But your solution seems good to me, I'll look into it further.
Have you tried using the
ATAC_MAIN_DIR
env variable before the features comes out?Have a great day
PS: do you have more knowledge on how to implement those things? I have some questions
I tried. Both these two ways work fine for me:
Thank you for your nice work! I have been longing for a tui Postman-like application for a long time.
What kind of knowledge do you need? I'm very glad to help but I lack experience and necessary knowledge.
I saw some links on the document page of the directories
crate which might help you.
What kind of knowledge do you need? I'm very glad to help but I lack experience and necessary knowledge. I saw some links on the document page of the
directories
crate which might help you.
I do not understand how the directory gets created, does I need to always try to create the directory when using the app ? Or does it needs something specific when installing?
Will it work with the ATAC_MAIN_DIR
variable or do I have to change the way it works?
Thanks in advance
What kind of knowledge do you need? I'm very glad to help but I lack experience and necessary knowledge. I saw some links on the document page of the
directories
crate which might help you.I do not understand how the directory gets created, does I need to always try to create the directory when using the app ? Or does it needs something specific when installing?
Will it work with the
ATAC_MAIN_DIR
variable or do I have to change the way it works?Thanks in advance
I think the directories
crate doesn't automatically create the project directory for us. So I suggest that ATAC create it if the directory
argument was not provided, the ATAC_MAIN_DIR
env variable was not provided and the project directory was not found.
I draw a flow chart to make it clear:
IMHO, a tui application can use the default directory specified by the OS, i.e:\n\nOS\tconfig directory\tcache directory\nLinux\t/home/alice/.config/barapp\t/home/alice/.cache/barapp\nWindows\tC:\Users\Alice\AppData\Roaming\Foo Corp\Bar App\config\tC:\Users\Alice\AppData\Local\Foo Corp\Bar App\cache\nMacOS\t/Users/Alice/Library/Application Support/com.Foo-Corp.Bar-App\t/Users/Alice/Library/Caches/com.Foo-Corp.Bar-App\n(Suppose the user name is Alice, the organization name is Foo Corp and the application name is Bar App).\n\nAll this can be easily handled by the directory crate:\n\n[dependencies]\ndirectories = \"5\"\n// these are just examples, there must be some other much more better options\n// and if you want the
ORGANIZATION
be present on Linux, some thing like#[cfg(target_os = \"linux\")]
can be used\npub const APP_NAME: &str = \"ATAC\";\npub const QUALIFIER: &str = \"fr\";\npub const ORGANIZATION: &str = \"Julien\";\n\nlet project_dir = directories::ProjectDirs::from(QUALIFIER, ORGANIZATION, APP_NAME).unwrap();\nlet config_dir = project_dir.config_dir();\nlet cache_dir = project_dir.cache_dir();\nlet mut log_dir = cache_dir.to_owned();\nlog_dir.push(\"logs\");
Please also consider that in addition of that, people might expect to respect XDG_CONFIG_HOME and XDG_DATA_HOME
https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
Does this crate respect that?
IMHO, a tui application can use the default directory specified by the OS, i.e:\n\nOS\tconfig directory\tcache directory\nLinux\t/home/alice/.config/barapp\t/home/alice/.cache/barapp\nWindows\tC:\Users\Alice\AppData\Roaming\Foo Corp\Bar App\config\tC:\Users\Alice\AppData\Local\Foo Corp\Bar App\cache\nMacOS\t/Users/Alice/Library/Application Support/com.Foo-Corp.Bar-App\t/Users/Alice/Library/Caches/com.Foo-Corp.Bar-App\n(Suppose the user name is Alice, the organization name is Foo Corp and the application name is Bar App).\n\nAll this can be easily handled by the directory crate:\n\n[dependencies]\ndirectories = "5"\n// these are just examples, there must be some other much more better options\n// and if you want the
ORGANIZATION
be present on Linux, some thing like#[cfg(target_os = \"linux\")]
can be used\npub const APP_NAME: &str = "ATAC";\npub const QUALIFIER: &str = "fr";\npub const ORGANIZATION: &str = "Julien";\n\nlet project_dir = directories::ProjectDirs::from(QUALIFIER, ORGANIZATION, APP_NAME).unwrap();\nlet config_dir = project_dir.config_dir();\nlet cache_dir = project_dir.cache_dir();\nlet mut log_dir = cache_dir.to_owned();\nlog_dir.push("logs");Please also consider that in addition of that, people might expect to respect XDG_CONFIG_HOME and XDG_DATA_HOME
https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
Does this crate respect that?
I'm not quite sure, maybe it does according to its comment:
Now ATAC (version 0.15.1) must be given a working directory on startup.![image](https://github.com/Julien-cpsn/ATAC/assets/3965259/8f36fa82-9487-4b12-a906-c5dd63a974d6)
/home/alice/.config/barapp
/home/alice/.cache/barapp
C:\Users\Alice\AppData\Roaming\Foo Corp\Bar App\config
C:\Users\Alice\AppData\Local\Foo Corp\Bar App\cache
/Users/Alice/Library/Application Support/com.Foo-Corp.Bar-App
/Users/Alice/Library/Caches/com.Foo-Corp.Bar-App
(Suppose the user name is
Alice
, the organization name isFoo Corp
and the application name isBar App
).All this can be easily handled by the
directory
crate: