Skip to content
This repository has been archived by the owner on Feb 19, 2024. It is now read-only.

Commit

Permalink
add - Initial files added
Browse files Browse the repository at this point in the history
  • Loading branch information
AptiviCEO committed Aug 14, 2023
0 parents commit 7447058
Show file tree
Hide file tree
Showing 22 changed files with 1,176 additions and 0 deletions.
16 changes: 16 additions & 0 deletions .github/ISSUE_TEMPLATE/ask-a-question.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
name: Ask a question
about: Ask us anything about Inxi.NET.
title: "[Q&A] [FeatureName] - [Question]"
labels: ''
assignees: ''

---

### -+--> Type of question
- [ ] General
- [ ] Parser
- [ ] Hardware
- [ ] Others

### -+--> Ask here
43 changes: 43 additions & 0 deletions .github/ISSUE_TEMPLATE/report-an-issue.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
---
name: Report an issue
about: Thank you for reporting a bug to us.
title: "[BUG] [featureName] - [issue]"
labels: ''
assignees: ''

---

### -+--> Description

<!-- Describe how this bug happened, and general information about it. Note that we only speak Arabic and English, so if you're on any other language than we know, then translate. -->
<!-- Note that you need to be as more descriptive as you can so we can understand this bug. -->


### -+--> Expected behavior

<!-- How do you expect Inxi.NET to behave on the suspected component. -->


### -+--> Actual behavior

<!-- What did the suspected component do instead? -->


### -+--> Steps to reproduce

<!-- Provide clear step-by-step instructions on how do you reporduce this bug. -->
1.
1.
1.

### -+--> System Information

<!-- This is here in case it's a hardware probing problem, but the probing should work normally. -->
- **OS:**
- **CPU:**
- **RAM:**
- **HDD:**

### -+--> Version (include commit number if applicable)

<!-- This should be in this format: <Version> (<Commit>) (<Branch>). Commit number and branch required for development builds. -->
18 changes: 18 additions & 0 deletions .github/ISSUE_TEMPLATE/request-a-feature.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
name: Request a feature
about: Suggest an idea to us.
title: "[ADD] [FeatureName] - [Feature]"
labels: ''
assignees: ''

---

### -+--> Description of new feature
<!--- Explain about a new feature here. --->


### -+--> What does it add?
- [ ] New hardware category
- [ ] Others

### -+--> Have you tried doing it?
38 changes: 38 additions & 0 deletions .github/issue_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
### -+--> Description

<!-- Describe how this bug happened, and general information about it. Note that we only speak Arabic and English, so if you're on any other language than we know, then translate. -->
<!-- Note that you need to be as more descriptive as you can so we can understand this bug. -->


### -+--> Expected behavior

<!-- How do you expect Inxi.NET to behave on the suspected component. -->


### -+--> Actual behavior

<!-- What did the suspected component do instead? -->


### -+--> Steps to reproduce

<!-- Provide clear step-by-step instructions on how do you reporduce this bug. -->
1.
1.
1.

### -+--> System Information

<!-- This is here in case it's a hardware probing problem, but the probing should work normally. -->
**OS:**

**CPU:**

**RAM:**

**HDD:**

### -+--> Version (include commit number if applicable)

<!-- This should be in this format: <Version> (<Commit>). Commit number required for development builds. -->

20 changes: 20 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
## Description
<!-- Describe about your pull request. Note that you need to be as more descriptive as you can so we can understand this request. -->


## Change type
<!-- Specify what kind of changes you made. -->
- [ ] Bug fixes
- [ ] Performance improvements
- [ ] Feature changes
- [ ] Behavioral changes
- [ ] Other (specify)

## Tested?
<!-- Have you tested your changes? -->
- [ ] Yes, I have
- [ ] No, I haven't
- [ ] Not sure

## Specify other changes
<!-- Specify the changes that wouldn't fit into the selection. -->
55 changes: 55 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Build Project

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

env:
CARGO_TERM_COLOR: always

jobs:
build-ubuntu:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Build
run: cargo build --verbose
- name: NuGlobal artifacts
uses: actions/upload-artifact@v3
if: success()
with:
name: ng-build-linux
path: "target/debug/"

build-windows:

runs-on: windows-latest

steps:
- uses: actions/checkout@v3
- name: Build
run: cargo build --verbose
- name: NuGlobal artifacts
uses: actions/upload-artifact@v3
if: success()
with:
name: ng-build-windows
path: "target/debug/"

notify:

runs-on: ubuntu-latest
needs:
- build-ubuntu
if: ${{ always() }}

steps:
- name: Notify
uses: nobrayner/discord-webhook@v1
with:
github-token: ${{ secrets.G_TOKEN }}
discord-webhook: ${{ secrets.DISCORD_WEBHOOK }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/target
/Cargo.lock
8 changes: 8 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[package]
name = "nuglobal"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
103 changes: 103 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
/*
* NuGlobal Copyright (C) 2023 Aptivi
*
* This file is part of NuGlobal
*
* NuGlobal is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* NuGlobal is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

use std::env;

mod ng_arg_handler;
mod ng_exec_handler;
mod ng_package_handler;
mod ng_error;
mod ng_cmds;

const NUGLOBAL_VERSION: &str = "0.1.0";

fn main() {
// Show version
println!("NuGlobal version {NUGLOBAL_VERSION}");
println!("Copyright (c) 2023 Aptivi");

// Handle arguments
let ng_args: Vec<String> = env::args().skip(1).collect();
let mut ng_mode = "";
let mut ng_mode_args: Vec<String> = vec![];
let mut ng_args_satisfied: bool = false;
dbg!(&ng_args);
dbg!(&ng_args.len());
if ng_args.len() > 0 {
// Parse the argument mode.
let ng_modes = ng_arg_handler::NG_AVAILABLE_MODES;
let ng_args_mode: &str = &ng_args[0];
dbg!(&ng_args_mode);

// Check to see if the mode is found within the available modes
for ng_mode_t in ng_modes {
let ng_mode_name = ng_mode_t.0;
let ng_mode_req_args = ng_mode_t.1;
dbg!(&ng_mode_name, &ng_mode_req_args);

// Check for equality
if ng_args_mode == ng_mode_name {
// Now, check for the number of provided arguments
let ng_env_mode_args: Vec<String> = env::args().skip(2).collect();
dbg!(&ng_env_mode_args);
dbg!(&ng_env_mode_args.len(), &ng_mode_req_args);
if ng_env_mode_args.len() >= ng_mode_req_args.try_into().unwrap() {
ng_args_satisfied = true;

// Install the results
ng_mode = ng_mode_name;
ng_mode_args = ng_env_mode_args;
}
}
}
}

// Handle execution
dbg!(&ng_args_satisfied, &ng_mode, &ng_mode_args);
if ng_args_satisfied {
let handle_exec = || -> Result<(), ng_error::NgError> {
ng_exec_handler::handle_exec(ng_mode, ng_mode_args)?;
Ok(())
};

if let Err(_err) = handle_exec() {
println!("An error occurred while performing a NuGlobal operation: {_err}")
}
}
else {
let args: Vec<String> = env::args().collect();
println!("Required arguments are not provided or mode not found. Help usage:\n");
println!("- {} install <group> <package>", &args[0]);
println!(" Adds a nupkg package to a group found in the per-user directory source (default is /etc/ng/packages/<group>)\n");
println!("- {} install-systemwide <group> <package>", &args[0]);
println!(" Adds a nupkg package to a group found in the systemwide directory source (default is $HOME/.config/ng/packages/<group>/)\n");
println!("- {} uninstall <group> <package>", &args[0]);
println!(" Removes a nupkg package from the per-user directory source\n");
println!("- {} uninstall-systemwide <group> <package>", &args[0]);
println!(" Removes a nupkg package from the systemwide directory source\n");
println!("- {} list <group>", &args[0]);
println!(" Lists installed nupkg packages in the per-user directory source\n");
println!("- {} list-systemwide <group>", &args[0]);
println!(" Lists installed nupkg packages in the systemwide directory source\n");
println!("- {} init <group> <target>", &args[0]);
println!(" Copies all the packages from the group to a target directory\n");
println!("- {} init-systemwide <group> <target>", &args[0]);
println!(" Copies all the packages from the systemwide group to a target directory\n");
}
}
30 changes: 30 additions & 0 deletions src/ng_arg_handler.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* NuGlobal Copyright (C) 2023 Aptivi
*
* This file is part of NuGlobal
*
* NuGlobal is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* NuGlobal is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

pub static NG_AVAILABLE_MODES: &'static [(&str, i32)] = &[
("install", 2),
("uninstall", 2),
("list", 1),
("init", 2),
("install-systemwide", 2),
("uninstall-systemwide", 2),
("list-systemwide", 1),
("init-systemwide", 2),
];

28 changes: 28 additions & 0 deletions src/ng_cmds.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* NuGlobal Copyright (C) 2023 Aptivi
*
* This file is part of NuGlobal
*
* NuGlobal is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* NuGlobal is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

pub mod ng_handle_install_cmd;
pub mod ng_handle_uninstall_cmd;
pub mod ng_handle_list_cmd;
pub mod ng_handle_init_cmd;
pub mod ng_handle_install_systemwide_cmd;
pub mod ng_handle_uninstall_systemwide_cmd;
pub mod ng_handle_list_systemwide_cmd;
pub mod ng_handle_init_systemwide_cmd;

Loading

0 comments on commit 7447058

Please sign in to comment.